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 response1 = new com.haitongauto.models.res.Response<>(); + String msg = ""; + if (truckNumber == null || truckNumber.isEmpty()) { + msg = "板车号不能为空"; + response1.setMsg(msg); + response1.setCode(-200); + return response1.toJSONString(); + } + //获取板车活跃预约 + Appointment appointment = appointmentService.getActiveAppointmentByTruckNumber(truckNumber); + Boolean b; + if (appointment == null) { + b = Boolean.FALSE; + msg = truckNumber + "不存在有效预约"; + response1.setMsg(msg); + response1.setCode(200); + response1.setData(b); + return response1.toJSONString(); + } + Integer appointment_type = appointment.getAppointment_type(); + switch (appointment_type) { + case 1: { + msg = truckNumber + "存在海通码头有效预约"; + b = Boolean.TRUE; + response1.setMsg(msg); + response1.setCode(200); + response1.setData(b); + break; + } + case 2: { + msg = truckNumber + "存在特保区有效预约"; + b = Boolean.TRUE; + response1.setMsg(msg); + response1.setCode(200); + response1.setData(b); + break; + } + } + return response1.toJSONString(); + + } + + /** + * 取消预约 + * + * @param appointment_id 预约id + * @return 返回执行取消预约的结果 + */ + @RequestMapping("/cancelAppointment") + public String cancelAppointment(@RequestParam("appointment_id") String appointment_id) { + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + Appointment myAppointment = appointmentService.getAppointmentById(appointment_id); + if (myAppointment != null) { + Integer appointment_state = myAppointment.getAppointment_state(); + if (appointment_state != null && (appointment_state.equals(6) || appointment_state.equals(7))) { + msg = "预约已完成,无须取消,请刷新页面"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + String plate_scan_time = myAppointment.getPlate_scan_time(); + //预约取消不受其他任何环节限制,故注释此处判断 (2024-7-16 王文文 提出) + //if (appointment_state != null && appointment_state.equals(5)) { + // msg = "作业已在进行中,不能取消预约"; + // //判断请求是否成功 + // Boolean bl = false; + // //创建返回数据 + // Map data = new HashMap<>(); + // //返回 + // return response.getResponseData(bl, data, msg); + //} + //特堡区预约取消处理 + Integer appointment_type = myAppointment.getAppointment_type(); + if (appointment_type.equals(2)) { + String pushIdstr = myAppointment.getPush_ids(); + List pushIds = null; + if (pushIdstr != null && !pushIdstr.isEmpty()) { + pushIds = Linq.of(pushIdstr.split(",")).toList(); + } + if (pushIds != null && pushIds.size() > 0) { + for (String pushId : pushIds) { + try { + logger.info("特保区预约,pushId:" + pushId + "智云取消请求"); + NarRes narRes = orderApi.vehicleCancelReserve(pushId); + logger.info("特保区预约,pushId:" + pushId + "智云取消请求返回:" + JSON.toJSONString(narRes)); + if (narRes == null) { + msg = "特保预约取消失败,智云消息:"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + if (!"S0000".equals(narRes.getCode())) { + msg = "特保预约取消失败,智云消息:" + narRes.getMsg(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + } catch (Exception ex) { + logger.info("特保区预约,pushId:" + pushId + "智云取消请求返回:" + JSON.toJSONString(ex.getMessage())); + msg = "特保预约取消失败,智云异常信息消息:" + ex.getMessage(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + } + pushIds.clear(); + } + } + } + Integer x = appointmentService.cancelAppointment(appointment_id); + //判断请求是否成功 + Boolean bl = x != null && x > 0; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", x); + //封装数据 + return response.getResponseData(bl, data); + } + + /** + * 无计划收车取消预约(app端无计划收车使用) + * + * @param appointment_id 预约id + * @return 返回执行取消预约的结果 + */ + @RequestMapping("/cancelAppointmentUnPlan") + public String cancelAppointmentUnPlan(@RequestParam("appointment_id") String appointment_id) { + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + Appointment myAppointment = appointmentService.getAppointmentById(appointment_id); + if (myAppointment != null) { + Integer appointment_state = myAppointment.getAppointment_state(); + if (appointment_state != null && (appointment_state.equals(6) || appointment_state.equals(7))) { + msg = "预约已完成,无须取消,请刷新页面"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + } + Integer x = appointmentService.cancelAppointment(appointment_id); + //判断请求是否成功 + Boolean bl = x != null && x > 0; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", x); + //封装数据 + return response.getResponseData(bl, data); + } + + /** + * 获取特保区进场车架号 + * + * @return 返回特保区进场车架号 + */ + public String getSpecialProtectionZoneVIN() { + //通过接口从客服平台数据库获取,模拟数据如下 + List vinData = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + String x = (i < 10) ? "0" + i : "" + i; + String vin = "abcdefghijklmno" + x; + vinData.add(vin); + } + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("vinData", vinData); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + /** + * 根据预约id查询预约信息和预约明细列表 + * + * @param appointment_id 预约id + * @return 返回预约信息和预约明细 + */ + @RequestMapping("/getAppointmentAndAppointmentDetailList") + public String getAppointmentAndAppointmentDetailList(@RequestParam("appointment_id") String appointment_id) { + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + Appointment appointment = appointmentService.getAppointmentById(appointment_id); + List appointmentDetailList = appointmentService.getAppointmentDetailListByAppointmentId(appointment_id); + + //判断请求是否成功 + Boolean bl = appointment != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("appointment", appointment); + data.put("appointmentDetailList", appointmentDetailList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 根据预约id查询预约信息 + * + * @param appointment_id 预约id + * @return 返回预约信息 + */ + @RequestMapping("/getAppointmentDtoByAppointmentId") + public String getAppointmentDtoByAppointmentId(@RequestParam("appointment_id") String appointment_id) { + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + AppointmentDto appointmentDto = appointmentService.getAppointmentDtoById(appointment_id); + List appointmentDetailList = appointmentService.getAppointmentDetailListByAppointmentId(appointment_id); + List chuanItemList = null; + try { + chuanItemList = covertChuanItemListDto1(appointmentDetailList); + } catch (Exception ex) { + } + + //判断请求是否成功 + Boolean bl = appointmentDto != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("appointmentDto", appointmentDto); + data.put("appointmentDetailList", appointmentDetailList); + data.put("chuanItemList", chuanItemList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * (出口/出口)进场计划船名/航次(计划审核通过) + * + * @param code 进港类型 + * @return 返回船名/航次(计划审核通过) + */ + @RequestMapping("/getPlanShipVoyList") + public String getPlanShipVoyList(@RequestParam("code") String code, + @RequestParam("q") String q, + @RequestParam("portAreaId") String portAreaId, + @RequestParam("current") Integer current, + @RequestParam("size") Integer size) { + List dataList = new ArrayList<>(); + switch (code) { + case "NE": { + //内贸出口 + CustomerRes> data = cusOrderApi.getNEOutPlanShipList(""); + List mydataList = data.getData(); + if (mydataList != null && mydataList.size() > 0) { + for (BasicDataIdo basicDataIdo : mydataList) { + ShipVoyIdo shipVoyIdo = new ShipVoyIdo(); + shipVoyIdo.setShipId(basicDataIdo.getId()); + shipVoyIdo.setShipName(basicDataIdo.getText() + "/" + basicDataIdo.getExtra1()); + shipVoyIdo.setShipEnName(basicDataIdo.getExtra1()); + dataList.add(shipVoyIdo); + } + } + break; + } + case "WE"://外贸出口 + { + CustomerRes> data = cusOrderApi.getWEOutPlanShipList(q, portAreaId, current, size); + dataList = data.getData(); + for (ShipVoyIdo ship : dataList) { + ship.setShipName(ship.getShipName() + "/" + ship.getShipEnName()); + } + break; + } + case "NI"://内贸进口 + case "WI"://外贸进口 + { + //CustomerRes> data = cusOrderApi.getInPlanShipVoyList(""); + //dataList = data.getData(); + break; + } + + case "BC": { + break; + } + + } + if (dataList != null && dataList.size() > 0) { + if (q != null && !q.isEmpty()) { + dataList = Linq.of(dataList).where(p -> p.getShipName().contains(q)).toList(); + } + } + + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("ShipList", dataList); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + /** + * (出口/出口)进场计划品牌 (计划审核通过) + * + * @param code 进港类型 + * @return 返回品牌 (计划审核通过) + */ + @RequestMapping("/getPlanBrandsList") + public String getPlanBrandsList(@RequestParam("code") String code, + @RequestParam("shipName") String shipName, + @RequestParam("voyage") String voyage, + @RequestParam("q") String q) { + String msg = ""; + if (shipName == null || shipName.isEmpty()) { + msg = "船名不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + //取船名的中文名 + shipName = shipName.split("/")[0]; + List dataList = null; + switch (code) { + case "NE"://内贸出口 + { + CustomerRes> data = cusOrderApi.getNEOutPlanBrandsList(q); + dataList = data.getData(); + if (dataList != null && dataList.size() > 0) { + for (BasicDataIdo item : dataList) { + String extra1 = item.getExtra1(); + if (extra1 != null && !extra1.isEmpty()) { + item.setText(item.getText() + "/" + extra1); + } else { + item.setText(item.getText() + "/"); + } + } + } + break; + } + case "WE"://外贸出口 + { + CustomerRes> data = cusOrderApi.getWEOutPlanBrandsList(q, shipName, 1, 100); + dataList = data.getData(); + if (dataList != null && dataList.size() > 0) { + for (BasicDataIdo item : dataList) { + String extra1 = item.getExtra1(); + if (extra1 != null && !extra1.isEmpty()) { + item.setText(item.getText() + "/" + extra1); + } + } + } + break; + } + case "NI"://内贸进口 + case "WI"://外贸进口 + { + CustomerRes> data = cusOrderApi.getInPlanBrandsList(q, shipName, voyage); + dataList = data.getData(); + } + break; + case "BC": { + break; + } + } + if (dataList != null && dataList.size() > 0) { + if (q != null && !q.isEmpty()) { + dataList = Linq.of(dataList).where(p -> p.getText().contains(q)).toList(); + } + } + + //判断请求是否成功 + Boolean bl = dataList != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("BrandsList", dataList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * (出口/出口)进场计划港口(计划审核通过) + * + * @return 返回 港口(计划审核通过) + */ + @RequestMapping("/getPlanPortsList") + public String getPlanPortsList(@RequestParam("code") String code, + @RequestParam("shipId") String shipId, + @RequestParam("q") String q) { + String msg = ""; + if (shipId == null || shipId.isEmpty()) { + msg = "船舶id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + List dataList = null; + switch (code) { + case "NE"://内贸出口 + { + CustomerRes> data = cusOrderApi.getNEOutPlanPortsList(q); + dataList = data.getData(); + if (dataList != null && dataList.size() > 0) { + for (BasicDataIdo item : dataList) { + String extra1 = item.getExtra1(); + if (extra1 != null && !extra1.isEmpty()) { + item.setText(item.getText() + "/" + extra1); + } else { + item.setText(item.getText() + "/"); + } + } + } + break; + } + case "WE"://外贸出口 出口进场计划的港口 + { + CustomerRes> data = cusOrderApi.getWEOutPlanPortsList(q, shipId, 1, 100); + dataList = data.getData(); + if (dataList != null && dataList.size() > 0) { + for (BasicDataIdo port : dataList) { + String extra1 = port.getExtra1(); + if (extra1 != null && !extra1.isEmpty()) { + port.setText(port.getText() + "/" + extra1); + } else { + port.setText(port.getText() + "/"); + } + } + } + break; + } + case "NI"://内贸进口 + case "WI"://外贸进口 + { + CustomerRes> data = cusOrderApi.getInPlanPortsList(q); + dataList = data.getData(); + } + break; + case "BC": { + break; + } + + } + if (dataList != null && dataList.size() > 0) { + if (q != null && !q.isEmpty()) { + dataList = Linq.of(dataList).where(p -> p.getText().contains(q)).toList(); + } + } + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("PortsList", dataList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * (出口/出口)进场计划港口(计划审核通过) + * + * @return 返回 港口(计划审核通过) + */ + @RequestMapping("/getGroupPlanPortsList") + public String getGroupPlanPortsList(@RequestParam("code") String code, + @RequestParam("shipIds") String shipIds) { + String msg = ""; + if (shipIds == null || shipIds.isEmpty()) { + msg = "船舶id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + List shipIdlist = Linq.of(shipIds.split(",")).toList(); + Dictionary> myGroupdata = new Hashtable<>(); + List dataList = null; + switch (code) { + case "NE"://内贸出口 + { + CustomerRes> data = cusOrderApi.getNEOutPlanPortsList(""); + dataList = data.getData(); + if (dataList != null && dataList.size() > 0) { + for (BasicDataIdo item : dataList) { + String extra1 = item.getExtra1(); + if (extra1 != null && !extra1.isEmpty()) { + item.setText(item.getText() + "/" + extra1); + } + } + } + + for (String shipId : shipIdlist) { + myGroupdata.put(shipId, dataList); + } + break; + } + case "WE"://外贸出口 + { + for (String shipId : shipIdlist) { + CustomerRes> data = cusOrderApi.getWEOutPlanPortsList("", shipId, 1, 100); + dataList = data.getData(); + myGroupdata.put(shipId, dataList); + } + break; + } + } + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("groupPortsList", myGroupdata); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * App收车扫描板车号(潘子航调用) + * + * @param appointmentId 预约id + * @return 结果 + */ + @PostMapping("/plateTruckScan") + public String plateTruckScan(@RequestParam("appointmentId") String appointmentId) { + String msg = ""; + if (appointmentId == null || appointmentId.isEmpty()) { + msg = "预约id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + int res = appointmentService.updateAppointmentPlateScanTime(appointmentId); + //判断请求是否成功 + Boolean bl = res > 0; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + + @PostMapping("/checkVinsISInShip") + public String checkVinsISInShipAndInPlan(@RequestParam("shipId") String shipId, + @RequestParam("vins") String vins) { + String msg = ""; + if (shipId == null || shipId.isEmpty()) { + msg = "船舶id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + if (vins == null || vins.isEmpty()) { + msg = "船舶id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + String oncvins = "";//需要 + if (oncvins == null || oncvins.isEmpty()) { + msg = "vin" + oncvins + "不属于该船,或者不在作业计划内"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + + } + + public List covertChuanItemListDto(List appointmentDetailList) { + if (appointmentDetailList == null || appointmentDetailList.size() == 0) { + return null; + } + List chuanItemList = new ArrayList<>(); + List shipIds = Linq.of(appointmentDetailList).select(AppointmentDetail::getShip_id).distinct().toList(); + for (String shipId : shipIds) { + ChuanItem chuanItem = new ChuanItem(); + AppointmentDetail appointmentDetailsh = Linq.of(appointmentDetailList).firstOrDefault(p -> p.getShip_id().equals(shipId)); + chuanItem.setIsOpen(true); + chuanItem.setShip_id(shipId); + chuanItem.setShip_name(appointmentDetailsh.getShip_name()); + chuanItem.setPort_name(appointmentDetailsh.getDestination_port()); + chuanItem.setPort_name_id(appointmentDetailsh.getDestination_port_id()); + //获得该船下所有的商品明细 + List commercialVehicleDetailslist = new ArrayList<>(); + List appointmentDetailListForShip = Linq.of(appointmentDetailList).where(p -> p.getShip_id().equals(shipId)).toList(); + List brandIds = Linq.of(appointmentDetailListForShip).select(AppointmentDetail::getBrand_id).distinct().toList(); + for (String brandId : brandIds) { + CommercialVehicleDetail commercialVehicleDetail = new CommercialVehicleDetail(); + AppointmentDetail appointmentDetailBr = Linq.of(appointmentDetailListForShip).firstOrDefault(p -> p.getBrand_id().equals(brandId)); + List appointmentDetailList_brand_items = Linq.of(appointmentDetailListForShip).where(p -> p.getBrand_id().equals(brandId)).toList(); + //List vins = Linq.of(appointmentDetailList_brand_items).select(AppointmentDetail::getVin).distinct().toList(); + //List vins = Linq.of(appointmentDetailList_brand_items).select(AppointmentDetail::getVin).toList(); + commercialVehicleDetail.setIsOpen(true); + commercialVehicleDetail.setBrand_id(appointmentDetailBr.getBrand_id()); + commercialVehicleDetail.setBrand(appointmentDetailBr.getBrand_name()); + List vinList = new ArrayList<>(); + if (appointmentDetailList_brand_items != null && appointmentDetailList_brand_items.size() > 0) { + for (AppointmentDetail vin : appointmentDetailList_brand_items) { + Vin myvin = new Vin(); + myvin.setVin(vin.getVin()); + myvin.setId(vin.getId()); + vinList.add(myvin); + } + } + + commercialVehicleDetail.setVehicle_frame_num(vinList); + commercialVehicleDetailslist.add(commercialVehicleDetail); + } + chuanItem.setCommercial_vehicle_details(commercialVehicleDetailslist); + chuanItemList.add(chuanItem); + } + return chuanItemList; + } + + public List covertChuanItemListDto1(List appointmentDetailList) { + if (appointmentDetailList == null || appointmentDetailList.size() == 0) { + return null; + } + List chuanItemList = new ArrayList<>(); + List shipIds = Linq.of(appointmentDetailList).select(AppointmentDetail::getShip_id).distinct().toList(); + for (String shipId : shipIds) { + List ports = Linq.of(appointmentDetailList).where(p -> p.getShip_id().equals(shipId)).select(AppointmentDetail::getDestination_port_id).distinct().toList(); + for (String port : ports) { + ChuanItem chuanItem = new ChuanItem(); + AppointmentDetail appointmentDetailsh = Linq.of(appointmentDetailList).firstOrDefault(p -> p.getShip_id().equals(shipId) && p.getDestination_port_id().equals(port)); + chuanItem.setIsOpen(false); + chuanItem.setShip_id(shipId); + chuanItem.setShip_name(appointmentDetailsh.getShip_name()); + chuanItem.setPort_name(appointmentDetailsh.getDestination_port()); + chuanItem.setPort_name_id(appointmentDetailsh.getDestination_port_id()); + //获得该船下所有的商品明细 + List commercialVehicleDetailslist = new ArrayList<>(); + List appointmentDetailListForShipAndPort = Linq.of(appointmentDetailList).where(p -> p.getShip_id().equals(shipId) && p.getDestination_port_id().equals(port)).toList(); + List brandIds = Linq.of(appointmentDetailListForShipAndPort).select(AppointmentDetail::getBrand_id).distinct().toList(); + for (String brandId : brandIds) { + CommercialVehicleDetail commercialVehicleDetail = new CommercialVehicleDetail(); + AppointmentDetail appointmentDetailBr = Linq.of(appointmentDetailListForShipAndPort).firstOrDefault(p -> p.getBrand_id().equals(brandId)); + List appointmentDetailList1 = Linq.of(appointmentDetailListForShipAndPort).where(p -> p.getBrand_id().equals(brandId)).toList(); + List vins = Linq.of(appointmentDetailList1).select(AppointmentDetail::getVin).toList(); + commercialVehicleDetail.setIsOpen(false); + commercialVehicleDetail.setBrand_id(appointmentDetailBr.getBrand_id()); + commercialVehicleDetail.setBrand(appointmentDetailBr.getBrand_name()); + List vinList = new ArrayList<>(); + for (String vin : vins) { + Vin myvin = new Vin(); + myvin.setVin(vin); + vinList.add(myvin); + } + commercialVehicleDetail.setVehicle_frame_num(vinList); + commercialVehicleDetailslist.add(commercialVehicleDetail); + } + chuanItem.setCommercial_vehicle_details(commercialVehicleDetailslist); + chuanItemList.add(chuanItem); + } + } + return chuanItemList; + } + + + /** + * 完成打卡提交,将完成状态同步到老系统(整车物流) + * + * @param appointment_id 预约id + * @param punch_clock_id 打卡id + * @param punch_address 打卡地点 + * @return + */ + @PostMapping("/appointmentOverApiAsync") + public String appointmentOverApiAsync(@RequestParam("appointment_id") String appointment_id, + @RequestParam("punch_clock_id") String punch_clock_id, + @RequestParam("punch_address") String punch_address) { + //打卡信息更新到数据库 + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + if (punch_address == null || punch_address.isEmpty()) { + msg = "打卡地点不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + logger.info("整车物流完成完工打卡:" + msg); + //封装数据 + return response.getResponseData(bl, data, msg); + } + Appointment myAppointment = appointmentService.getAppointmentById(appointment_id); + PunchClock myPunchClock = punchClockService.getPunchClockForAppintementId(appointment_id); + + if (myAppointment == null) { + msg = "不存预约Id为" + appointment_id + "的预约信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + logger.info("整车物流完成完工打卡:" + msg); + //封装数据 + return response.getResponseData(bl, data, msg); + } + Integer appointment_state = myAppointment.getAppointment_state(); + if (appointment_state != null && appointment_state.equals(4)) { + msg = "预约id" + appointment_id + "的预约,已被取消,不能完工打卡!"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + logger.info("整车物流完成完工打卡:" + msg); + return response.getResponseData(bl, data, msg); + } + if (myPunchClock == null) { + msg = "不存预约Id为" + appointment_id + "的打卡记录信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + logger.info("整车物流完成完工打卡:" + msg); + //封装数据 + return response.getResponseData(bl, data, msg); + } + PunchClock punchClock = null; + ForwardRes forwardRes = null; + if (true) { + //注意:此处还需追加完成打卡后生成指令,并提交到哪吒接口 + //将完成状态同步到老系统(整车物流) + AppointOverState appointOverState = new AppointOverState(); + appointOverState.setTruckNo(myAppointment.getTruck_number()); + Truck myTruck = usersService.getTruckByUserId(myAppointment.getUsers_id()); + Date datetime = new Date(); + appointOverState.setWorkTm(FormatDateTime.dateTimeToStr(datetime)); + if (myTruck != null) { + appointOverState.setOpenId(myTruck.getWx_openid()); + } + if (!"3".equals(myAppointment.getTransport_type())) { + String myUrl = "http://192.168.161.81:8090/rtopswebapi/api/NsOrder/execTruckOrderNsFin"; + myUrl = expressUrl; + try { + logger.info("预约完成状态,同步老系统:" + JSON.toJSONString(appointOverState)); + String post = OkHttpUtils.post(myUrl, OkHttpUtils.buildJsonRequestBody(JSON.toJSONString(appointOverState)), null); + JSONObject rst = JSONObject.parseObject(post); + logger.info("预约完成状态,同步老系统返回:" + JSONObject.toJSONString(rst)); + //解析成实体 + if (post != null && post.contains("success")) { + forwardRes = JSONObject.parseObject(post, ForwardRes.class); + } + } catch (Exception e) { + logger.info("预约完成状态,同步老系统返回:" + JSON.toJSONString(e.getMessage())); + msg = "预约完成状态,同步老系统返回:" + JSON.toJSONString(e.getMessage()); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + if (forwardRes != null && "0".equals(forwardRes.getSuccess())) { + logger.info("预约完成状态同步,老系统返回:" + forwardRes.getErrmsg()); + msg = "预约完成状态同步,老系统返回:" + forwardRes.getErrmsg(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + return response.getResponseData(bl, data, msg); + } + //只有同步后才能,完成新系统打卡 + if (forwardRes != null && "1".equals(forwardRes.getSuccess())) { + punchClock = punchClockService.postPunchClockOver(appointment_id, punch_clock_id, punch_address); + } + } else { + //非自开 + punchClock = punchClockService.postPunchClockOver(appointment_id, punch_clock_id, punch_address); + } + + } + + + // punchClock = punchClockService.postPunchClockOver(appointment_id, punch_clock_id, punch_address); + //获取签到打卡的日期时间(年月日小时分钟秒) + String punch_date = ""; + String punch_time = ""; + String punch_date_time = ""; + if (punchClock != null) { + String[] strArray = punchClock.getOver_time().split(" "); + //转换为两位数格式字符串 + punch_date = strArray[0]; + punch_time = strArray[1]; + punch_date_time = punch_date + " " + punch_time; + } + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("punch_time", punch_date_time); + data.put("punch_address", punch_address); + //封装数据 + return response.getResponseData(bl, data); + } + + + /** + * 哪吒老系统完成预约,需要调用该接口,完成新系统的预约打卡 + * + * @param appointOverState 预约完成状态 + * @return 返回结果 + */ + @PostMapping("/execTruckOrderNsFin") + public String execTruckOrderNsFin(@RequestBody AppointOverState appointOverState) { + logger.info("老系统完成预约,入参:" + JSON.toJSONString(appointOverState)); + ForwardRes forwardRes = new ForwardRes(); + forwardRes.setSuccess("0"); + forwardRes.setErrmsg(""); + String msg = ""; + if (appointOverState == null) { + msg = "传参不能为空"; + forwardRes.setSuccess("0"); + forwardRes.setErrmsg(msg); + logger.info("老系统完成预约,返回:" + msg); + return JSON.toJSONString(forwardRes); + } + String openId = appointOverState.getOpenId(); + String truckNo = appointOverState.getTruckNo(); + if (openId == null || openId.isEmpty()) { + msg = "openId不能为空"; + forwardRes.setSuccess("0"); + forwardRes.setErrmsg(msg); + logger.info("老系统完成预约,返回:" + msg); + return JSON.toJSONString(forwardRes); + } + if (truckNo == null || truckNo.isEmpty()) { + msg = "truckNo不能为空"; + forwardRes.setSuccess("0"); + forwardRes.setErrmsg(msg); + logger.info("老系统完成预约,返回:" + msg); + return JSON.toJSONString(forwardRes); + } + Appointment myAppointment = appointmentService.getAppointmentByTruckNo(truckNo); + if (myAppointment == null) { + msg = "新系统中,没有找到车辆" + truckNo + "的有效预约,或者已经打卡完成,无需再次打卡"; + forwardRes.setSuccess("0"); + forwardRes.setErrmsg(msg); + logger.info("老系统完成预约,返回:" + msg); + return JSON.toJSONString(forwardRes); + } + //完成打卡操作 + Appointment appointment = messageService.punchClockOverByPrint(myAppointment.getId()); + if (appointment != null) { + msg = "新系统中,车辆" + truckNo + "预约完成打卡成功"; + forwardRes.setSuccess("1"); + } else { + msg = "新系统中,车辆" + truckNo + "预约完成打卡失败"; + forwardRes.setSuccess("0"); + } + forwardRes.setErrmsg(msg); + JSON.toJSONString(forwardRes); + logger.info("老系统完成预约,返回:" + msg); + return JSON.toJSONString(forwardRes); + } + + /** + * 获得腾讯 mapKey(王琛需要) + * + * @return + */ + @PostMapping("/getMK") + public String getMK() { + String mapKey = "FUFBZ-KBIWW-P63RR-RR4W3-BNV4H-T6BGX"; + //判断请求是否成功 + Boolean bl = true; + //封装数据 + return response.getResponseData(bl, mapKey); + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/HeathCheckController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/HeathCheckController.java new file mode 100644 index 0000000..e6967c9 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/HeathCheckController.java @@ -0,0 +1,19 @@ +package com.haitongauto.rtosac.api; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/health") +public class HeathCheckController { + /** + * 健康检查(服务心跳) + * @return + */ + @GetMapping("/ping") + public String ping() { + return "pong"; + } + +} \ No newline at end of file diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/HomeController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/HomeController.java new file mode 100644 index 0000000..f86473c --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/HomeController.java @@ -0,0 +1,376 @@ +package com.haitongauto.rtosac.api; + +import com.haitongauto.interfaces.OrderApi; +import com.haitongauto.interfaces.UsersApi; +import com.haitongauto.models.dto.AnnouncementsDto; +import com.haitongauto.models.ido.CommonRes; +import com.haitongauto.models.ido.PortAreasIdo; +import com.haitongauto.models.ido.login.UserInfoRes; +import com.haitongauto.models.pojo.Announcement; +import com.haitongauto.models.pojo.Truck; +import com.haitongauto.models.pojo.Users; +import com.haitongauto.models.sysuser.OldSysTruck; +import com.haitongauto.models.sysuser.OldSysUT; +import com.haitongauto.models.sysuser.OldSysUTDto; +import com.haitongauto.models.sysuser.OldSysUser; +import com.haitongauto.rtosac.service.Response; +import com.haitongauto.models.dto.DataForMessage; +import com.haitongauto.models.dto.Pages; +import com.haitongauto.rtosac.service.HomeService; +import com.haitongauto.rtosac.service.UsersService; +import com.haitongauto.utils.IpHelper; +import com.haitongauto.utils.StringHelper; +import com.haitongauto.utils.minio.MinioUtils; +import io.minio.errors.InvalidEndpointException; +import io.minio.errors.InvalidPortException; +import org.apache.commons.lang3.StringEscapeUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import com.github.pagehelper.PageInfo; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/home") +public class HomeController { + /** + * 头部信息 + */ + @Autowired + HttpServletRequest servletRequest; + @Autowired + HomeService homeService; + @Autowired + Response response; + @Autowired + UsersService usersService; + @Resource + private UsersApi usersApi; + @Resource + private OrderApi orderApi; + + + /** + * 提供给哪吒调用的接口,用于老系统用户和板车信息同步到新系统 + * "wx_openid":"bbaaaaaaaaaaaaaa", + * "tel_number":"15102735688", + * + * @return + */ + @PostMapping("/userInfoSync") + public String userInfoSync(@RequestBody OldSysUTDto oldSysUTDto) { + com.haitongauto.models.res.Response myResponse = new com.haitongauto.models.res.Response(); + if (oldSysUTDto == null) { + myResponse.setCode(-200); + myResponse.setMsg("传参不能为空"); + return myResponse.toJSONString(); + } + String wx_openid = oldSysUTDto.getWx_openid(); + String tel_number = oldSysUTDto.getTel_number(); + if (wx_openid == null || wx_openid.isEmpty()) { + myResponse.setCode(-200); + myResponse.setMsg("微信openid不能为空"); + return myResponse.toJSONString(); + } + if (tel_number == null || tel_number.isEmpty()) { + myResponse.setCode(-200); + myResponse.setMsg("手机号不能为空"); + return myResponse.toJSONString(); + } + try { + myResponse.setCode(200); + Users users = homeService.userInfoSync(wx_openid, tel_number); + if (users == null) { + myResponse.setCode(-200); + myResponse.setMsg("数据库不存在该用户记录"); + return myResponse.toJSONString(); + } + + } catch (Exception ex) { + myResponse.setCode(500); + myResponse.setMsg(ex.getMessage()); + return myResponse.toJSONString(); + } + return myResponse.toJSONString(); + + } + + + /** + * 用户登录:提交用户信息(users信息要保持完整:open_id、session_key、access_token,及用户),登陆RTOS系统:需要RTOS系统排除拦截 + * + * @param users 用户信息 + * @return 返回 + */ + @PostMapping("/onLogin") + public String onLogin(@RequestBody Users users) { + //请求哪吒接口获得用户信息 + CommonRes userInfoResCommonRes = usersApi.getUserInfo(); + UserInfoRes userInfoRes = userInfoResCommonRes.getData(); + String msg = ""; + //检查本地数据库是否有该用户 + Users my_users = null; + if (userInfoRes != null && userInfoRes.getId() != null && !userInfoRes.getId().isEmpty()) { + users.setId(userInfoRes.getId()); + users.setWx_openid(userInfoRes.getOpenId()); + my_users = homeService.getUsersForId(userInfoRes.getId()); + } + if (my_users != null) { + users.setId(my_users.getId()); + if (users.getUsers_name() == null || users.getUsers_name().isEmpty()) { + users.setUsers_name(my_users.getUsers_name()); + } + if (users.getId_code() == null || users.getId_code().isEmpty()) { + users.setId_code(my_users.getId_code()); + } + if (users.getTel_number() == null || users.getTel_number().isEmpty()) { + users.setTel_number(my_users.getTel_number()); + } + } + String users_id = (my_users != null) ? my_users.getId() : null; + //更新到入本地数据库(保存用户的openid和rtos的token) + if (users_id != null && !users_id.isEmpty()) { + Integer x = usersService.update(users); + } else { + String id = usersService.insert(users); + users.setId(id); + } + + Truck myTruck = null; + myTruck = usersService.getTruckByWxOpenID(users.getWx_openid()); + if (myTruck != null && my_users != null) { + users.setId(users.getId()); + users.setUsers_name(my_users.getUsers_name()); + } + + assert userInfoRes != null; + my_users = homeService.getUsersForId(userInfoRes.getId()); + + //1-先获取用户登录IP + String ip = IpHelper.getIpAddr(servletRequest); + //2-登录日志写如数据库 + homeService.loginLogAdd(users.getWx_openid(), ip); + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("users", my_users); + data.put("truck", myTruck); + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 保存前端提交车辆信息 + * + * @param truck 车辆信息 + * @return 返回 + */ + @PostMapping("/truckBanding") + public String truckBanding(@RequestBody Truck truck) { + CommonRes userInfoResCommonRes; + String userId; + String msg = ""; + if (truck == null || truck.getTruck_number().isEmpty()) { + msg = "用户车辆信息不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + try { + //请求哪吒接口获得用户信息 + userInfoResCommonRes = usersApi.getUserInfo(); + UserInfoRes userInfoRes = userInfoResCommonRes.getData(); + userId = userInfoRes.getId(); + truck.setUsers_id(userId); + } catch (Exception ex) { + msg = "从rtos后台,获得用户信息异常," + ex.getMessage(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + + String truck_id = truck.getId(); + Truck myTruck = null; + String openid = ""; + if (truck.getWx_openid() != null && !truck.getWx_openid().isEmpty()) { + openid = truck.getWx_openid(); + myTruck = usersService.getTruckByWxOpenID(openid); + if (myTruck != null) { + truck.setUsers_id(myTruck.getUsers_id()); + truck.setId(myTruck.getId()); + if (openid != null && !openid.isEmpty()) { + truck.setWx_openid(openid); + } + } + } else { + //请求哪吒接口获得用户信息 + UserInfoRes userInfoRes = userInfoResCommonRes.getData(); + openid = userInfoRes.getOpenId(); + truck.setWx_openid(openid); + truck.setUsers_id(userInfoRes.getId()); + } + if (myTruck != null) { + truck_id = myTruck.getId(); + } + //更新到数据库 + if (truck_id != null && !truck_id.isEmpty()) { + Integer x = homeService.updateTruck(truck); + truck_id = truck.getId(); + } else { + truck_id = homeService.insertTruck(truck); + truck.setId(truck_id); + } + Boolean bl = truck_id != null && !truck_id.isEmpty(); + //创建返回数据 + Map data = new HashMap<>(); + data.put("truck", truck); + //返回 + return response.getResponseData(bl, data); + } + + /** + * 分页读取每页10条公告数据 + * + * @return 返回分页公告数据 + */ + @RequestMapping("/getAnnouncementsList") + public String getAnnouncementsList(Pages pages, Integer sort, String keyWords) { + //解析分页参数 + Integer pageNum = (pages != null && pages.getPageNum() != null && pages.getPageNum() > 0) ? pages.getPageNum() : 1; + Integer pageSize = (pages != null) && pages.getPageSize() != null && pages.getPageSize() > 0 ? pages.getPageSize() : 10; + //调用Service分页方法,获取分页数据对象PageInfo + PageInfo pagesInfo = homeService.getAnnouncementsList(pageNum, pageSize, sort, keyWords); + //读取分页结果 + int pageCount = 0; //总页数 + long recordTotal = 0; //记录总数 + List myList = null; //当前页的列表数据 + List myListres = null; //当前页的列表数据 + if (pagesInfo != null) { + pageCount = pagesInfo.getPages(); //总页数 + recordTotal = pagesInfo.getTotal(); //记录总数 + myList = pagesInfo.getList(); //当前页的列表数据 + } + if (myList != null && myList.size() > 0) { + myListres = new ArrayList<>(); + for (Announcement announcement : myList) { + if (announcement != null) { + AnnouncementsDto announcementsDto = new AnnouncementsDto(); + announcementsDto.setId(announcement.getId()); + announcementsDto.setTitle(announcement.getTitle()); + announcementsDto.setSort(announcement.getSort()); + if (announcement.getSort() != null) { + switch (announcement.getSort()) { + case 1: + announcementsDto.setSort_name("小程序"); + break; + case 2: + announcementsDto.setSort_name("客服平台"); + break; + } + } + announcementsDto.setAbstracts(announcement.getAbstracts()); + String content = announcement.getAnnouncement(); + if (content != null && !content.isEmpty()) { + String decodedHtml = StringEscapeUtils.unescapeHtml4(content); + announcementsDto.setAnnouncement(decodedHtml); + announcementsDto.setAnnouncement_text(StringHelper.getTxtByHtml(decodedHtml)); + } + announcementsDto.setAuthor(announcement.getAuthor()); + announcementsDto.setReading_volume(announcement.getReading_volume()); + if (announcement.getCreate_time() != null) { + announcementsDto.setCreate_time(announcement.getCreate_time()); + } + if (announcement.getUpdate_time() != null) { + announcementsDto.setUpdate_time(announcement.getUpdate_time()); + } + announcementsDto.setIs_del(announcement.getIs_del()); + myListres.add(announcementsDto); + } + } + + } + //定义返回数据 + Map data = new HashMap<>(); + data.put("pageNum", pageNum); + data.put("pageCount", pageCount); + data.put("recordTotal", recordTotal); + data.put("dataJson", myListres); + Boolean bl = myListres != null; + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 根据公告id获得公告 + * + * @param announcement_id 公告id + * @return 返回公告信息 + */ + @RequestMapping("/getAnnouncementById") + public String getAnnouncementById(@RequestParam("announcement_id") String announcement_id) { + String msg = ""; + if (announcement_id == null || announcement_id.isEmpty()) { + msg = "公告id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + //调用Service分页方法,获取分页数据对象PageInfo + Announcement announcement = homeService.getAnnouncementById(announcement_id); + AnnouncementsDto announcementsDto = new AnnouncementsDto(); + if (announcement != null) { + announcementsDto.setId(announcement.getId()); + announcementsDto.setTitle(announcement.getTitle()); + announcementsDto.setSort(announcement.getSort()); + if (announcement.getSort() != null) { + switch (announcement.getSort()) { + case 1: + announcementsDto.setSort_name("小程序"); + break; + case 2: + announcementsDto.setSort_name("客服平台"); + break; + } + } + announcementsDto.setAbstracts(announcement.getAbstracts()); + String content = announcement.getAnnouncement(); + if (content != null && !content.isEmpty()) { + String decodedHtml = StringEscapeUtils.unescapeHtml4(content); + announcementsDto.setAnnouncement(decodedHtml); + announcementsDto.setAnnouncement_text(StringHelper.getTxtByHtml(decodedHtml)); + } + announcementsDto.setAuthor(announcement.getAuthor()); + announcementsDto.setReading_volume(announcement.getReading_volume()); + if (announcement.getCreate_time() != null) { + announcementsDto.setCreate_time(announcement.getCreate_time()); + } + if (announcement.getUpdate_time() != null) { + announcementsDto.setUpdate_time(announcement.getUpdate_time()); + } + announcementsDto.setIs_del(announcement.getIs_del()); + } + Boolean bl = announcement != null; + //定义返回数据 + Map data = new HashMap<>(); + data.put("announcementInfo", announcementsDto); + return response.getResponseDataJavaJson(bl, data); + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/MessageController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/MessageController.java new file mode 100644 index 0000000..60d5ef5 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/MessageController.java @@ -0,0 +1,225 @@ +package com.haitongauto.rtosac.api; + +import com.bestvike.linq.Linq; +import com.github.pagehelper.PageInfo; +import com.haitongauto.models.dto.Pages; +import com.haitongauto.models.pojo.Appointment; +import com.haitongauto.models.pojo.Message; +import com.haitongauto.rtosac.service.AppointmentService; +import com.haitongauto.rtosac.service.MessageService; +import com.haitongauto.rtosac.service.Response; +import com.haitongauto.rtosac.service.impl.AppointmentServiceImpl; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.*; + +@RestController +@RequestMapping("/message") +public class MessageController { + @Autowired + MessageService messageService; + + @Autowired + AppointmentService appointmentService; + + @Autowired + Response response; + + private static final Logger logger = LogManager.getLogger(AppointmentServiceImpl.class); + + /** + * 哪吒打印的时候向小程序发送消息(哪吒请求接口) + * + * @param message 消息实体 + * @return 返回结果 + */ + @PostMapping("/realMessage") + public String realMessage(@RequestBody Message message) { + //判断请求是否成功 + Boolean bl = messageService.receiveMessage(message); + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + return response.getResponseData(bl, data); + } + + /** + * 微信小程序前端打开界面,获得未消息列表, + * + * @param open_id 板车号 + * @return 返回结果 + */ + @GetMapping("/getUnReadMessageListByOpenId") + public String getUnReadMessageListByOpenId(@RequestParam("open_id") String open_id, + @RequestParam("pageNum") Integer pageNum, + @RequestParam("pageSize") Integer pageSize) { + pageNum = (pageNum != null) ? pageNum : 1; + pageSize = (pageSize != null) ? pageSize : 10; + //判断请求是否成功 + PageInfo pagesInfo = messageService.getUnReadMessageListByWxOpenid(open_id, pageNum, pageSize); + //读取分页结果 + Integer pageCount = pagesInfo.getPages();//总页数 + long recordTotal = pagesInfo.getTotal();//记录总数 + List myList = new ArrayList<>();//当前页的列表数据 + Pages pages = new Pages(); + int noReadSize = 0; + if (pageNum <= pageCount) { + myList = pagesInfo.getList();//当前页的列表数据 + if (myList != null && myList.size() > 0) { + noReadSize = Linq.of(myList).where(p -> p.getIs_read().equals(0)).count(); + } + + pages.setUnReadSize(noReadSize); + } + //分页数据添加到pages + pages.setPageNum(pageNum); + pages.setPageSize(pageSize); + pages.setPageCount(pageCount); + pages.setRecordTotal(recordTotal); + //判断请求是否成功 + Boolean bl = myList != null; + //创建返回数据data + Map data = new HashMap<>(); + data.put("pages", pages); + data.put("messageList", myList); + //添加到返回对象 + //返回 + return response.getResponseDataJavaJson(bl, data); + + } + + /** + * 微信小程序前端打开界面,获得所有消息列表, + * + * @param open_id 板车号 + * @return 返回结果 + */ + @GetMapping("/getMessageListByOpenId") + public String getMessageListByOpenId(@RequestParam("open_id") String open_id, + @RequestParam("pageNum") Integer pageNum, + @RequestParam("pageSize") Integer pageSize) { + pageNum = (pageNum != null) ? pageNum : 1; + pageSize = (pageSize != null) ? pageSize : 10; + //判断请求是否成功 + PageInfo pagesInfo = messageService.getMessageListByWxOpenid(open_id, pageNum, pageSize); + //读取分页结果 + Integer pageCount = pagesInfo.getPages();//总页数 + long recordTotal = pagesInfo.getTotal();//记录总数 + List myList = new ArrayList<>();//当前页的列表数据 + Pages pages = new Pages(); + int noReadSize = 0; + if (pageNum <= pageCount) { + myList = pagesInfo.getList();//当前页的列表数据 + if (myList != null && myList.size() > 0) { + //noReadSize = Linq.of(myList).where(p -> Objects.equals(p.getIs_read(), 0)).count(); + //Message message = Linq.of(myList).firstOrDefault(); + //未读数据查所有未读的站内消息数量 + noReadSize = messageService.sumUnread(open_id); + } + pages.setUnReadSize(noReadSize); + } + //分页数据添加到pages + pages.setPageNum(pageNum); + pages.setPageSize(pageSize); + pages.setPageCount(pageCount); + pages.setRecordTotal(recordTotal); + //判断请求是否成功 + Boolean bl = myList != null; + //创建返回数据data + Map data = new HashMap<>(); + data.put("pages", pages); + data.put("messageList", myList); + //添加到返回对象 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 微信小程序前端点看信息后,修改信息状态为已看, + * + * @param id id + * @return 返回结果 + */ + @PostMapping("/setHavingLookMessageState") + public String setHavingLookMessageState(@RequestParam("id") String id) { + String msg = ""; + if (id == null || id.isEmpty()) { + msg = "Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + Message message = new Message(); + message.setId(id); + message.setIs_read(1); + int res = messageService.update(message); + //判断请求是否成功 + Boolean bl = res > 0; + Map data = new HashMap<>(); + return response.getResponseData(bl, data); + } + + /** + * 通过打印小票环节完成完工打卡 + * + * @param appointmentId 预约id + */ + @GetMapping("/punchClockOverByPrint") + public String punchClockOverByPrint(@RequestParam("appointmentId") String appointmentId) { + String msg; + if (appointmentId == null || appointmentId.isEmpty()) { + msg = "预约id不能为空!"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + data.put("message", msg); + logger.info("通过打印小票环节完成完工打卡:" + msg); + //返回 + return response.getResponseData(bl, data, msg); + } + Appointment myappointment = appointmentService.getAppointmentById(appointmentId); + if (myappointment == null) { + msg = "预约id" + appointmentId + "的预约,不存在!"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + data.put("message", msg); + logger.info("通过打印小票环节完成完工打卡:" + msg); + return response.getResponseData(bl, data, msg); + } + //完工打卡不受预约是否取消制约,依然可以完工打卡,故注释此处判断 (2024-7-16 王文文 提出) + //Integer appointment_state = myappointment.getAppointment_state(); + //if (appointment_state != null && appointment_state.equals(4)) { + // msg = "预约id" + appointmentId + "的预约,已被取消,不能完工打卡!"; + // //判断请求是否成功 + // Boolean bl = false; + // //创建返回数据 + // Map data = new HashMap<>(); + // data.put("result", bl); + // data.put("message", msg); + // logger.info("通过打印小票环节完成完工打卡:" + msg); + // return response.getResponseData(bl, data, msg); + //} + Appointment appointment = messageService.punchClockOverByPrint(appointmentId); + logger.info("通过打印小票环节完成完工打卡:预约id" + appointmentId + "的预约完成打卡成功"); + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + return response.getResponseData(bl, data); + } + + +} \ No newline at end of file diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/MineController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/MineController.java new file mode 100644 index 0000000..5d74bd6 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/MineController.java @@ -0,0 +1,1027 @@ +package com.haitongauto.rtosac.api; + +import com.alibaba.fastjson.JSONObject; +import com.bestvike.linq.Linq; +import com.github.pagehelper.PageInfo; +import com.haitongauto.interfaces.OrderApi; +import com.haitongauto.interfaces.UsersApi; +import com.haitongauto.models.dto.CurrentDayPunchClockDto; +import com.haitongauto.models.dto.Pages; +import com.haitongauto.models.forward.ForwardRes; +import com.haitongauto.models.forward.UserTruck; +import com.haitongauto.models.ido.CommonRes; +import com.haitongauto.models.ido.login.UserInfoRes; +import com.haitongauto.models.ido.login.UsersIdo; +import com.haitongauto.models.pojo.*; +import com.haitongauto.rtosac.service.*; +import com.haitongauto.utils.DateTimeHelper; +import com.haitongauto.utils.FormatDateTime; +import com.haitongauto.utils.HttpClientHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +@RestController +@RequestMapping("/mine") +public class MineController { + @Autowired + MineService mineService; + + @Autowired + PunchClockService punchClockService; + @Autowired + AppointmentService appointmentService; + @Autowired + ForwardService forwardService; + @Autowired + Response response; + @Resource + OrderApi orderApi; + + @Resource + private UsersApi usersApi; + + private static final Lock lock = new ReentrantLock(); + + /** + * 获取个人资料 + * + * //@param users_id:司机用户id + * @return 返回完整的个人信息 + */ + @RequestMapping("/getUsersInfo") + //public String getUsersInfo(@RequestParam("users_id") String users_id) + public String getUsersInfo() { + 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); + } + Users myusers = mineService.getUsersById(userId); + //判断请求是否成功 + Boolean bl = myusers != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("Users", myusers); + //封装数据 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 个人资料修改 + * @param users:修改后的个人信息 + * @return 是否修改成功 + */ + @PostMapping("/postUsersInfo") + public String postUsersInfo(@RequestBody Users users) { + CommonRes userInfoResCommonRes; + String userId; + String msg = ""; + try { + //请求哪吒接口获得用户信息 + userInfoResCommonRes = usersApi.getUserInfo(); + UserInfoRes userInfoRes = userInfoResCommonRes.getData(); + userId = userInfoRes.getId(); + users.setId(userId); + } catch (Exception ex) { + msg = "从rtos后台,获得用户信息异常," + ex.getMessage(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + if (users.getTel_number() == null || users.getTel_number().isEmpty()) { + msg = "手机号不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + String usersId = userId; + if (usersId != null && !usersId.isEmpty()) { + //有预约的时候不能删除车辆 或者修改个人信息(王琛) + Appointment myAppointment = appointmentService.getActiveAppointment(usersId); + if (myAppointment != null) { + msg = "用户当前存在有效预约,不能修改用户信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + } + + //保存本地数据库 + Integer x = null; + try { + x = mineService.postMyUsers(users); + } catch (Exception ex) { + msg = ex.getMessage(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + + //将用户提交为哪吒 + UsersIdo usersIdo = new UsersIdo(); + usersIdo.setIdCard(users.getId_code()); + usersIdo.setName(users.getUsers_name()); + usersIdo.setPhone(users.getTel_number()); + //待开放 + // CommonRes res = orderApi.updateUser(usersIdo); + // String res = orderApi.updateUser(usersIdo); + // System.out.print(res); + // 判断请求是否成功 + Boolean bl = x != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", x); + //封装数据 + return response.getResponseData(bl, data); + } + + /** + * 获取我的板车信息 pallet_truck + * + * @return 返回我的板车信息 pallet_truck + */ + @RequestMapping("/getMyPalletTruck") + public String getMyPalletTruck() { + String msg = ""; + CommonRes userInfoResCommonRes; + String userId; + 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); + } + //获取我的板车信息(含被列入黑名单的最新信息) + List myPalletTruckList = mineService.getMyPalletTruck(userId); + //判断请求是否成功 + Boolean bl = myPalletTruckList != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("PalletTruckList", myPalletTruckList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 修改我的板车信息 + * + * @param truck:修改后的我的板车信息 + * @return 是否修改成功 + */ + @PostMapping("/postMyPalletTruck") + public String postMyPalletTruck(@RequestBody Truck truck) { + CommonRes userInfoResCommonRes; + String userId; + String msg = ""; + try { + //请求哪吒接口获得用户信息 + userInfoResCommonRes = usersApi.getUserInfo(); + UserInfoRes userInfoRes = userInfoResCommonRes.getData(); + userId = userInfoRes.getId(); + truck.setUsers_id(userId); + } catch (Exception ex) { + msg = "从rtos后台,获得用户信息异常," + ex.getMessage(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + String users_id = truck.getUsers_id(); + String truck_number = truck.getTruck_number(); + if (users_id == null || users_id.isEmpty()) { + msg = "用户Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + if (truck_number == null || truck_number.isEmpty()) { + msg = "板车号不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + + //有预约的时候不能删除车辆 或者修改个人信息(王琛) + Appointment myAppointment = appointmentService.getActiveAppointment(users_id); + if (myAppointment != null) { + msg = "用户当前存在有效预约,不能修改板车信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + Integer x = null; + try { + lock.lock(); + truck.setTruck_state(1); + x = mineService.postMyPalletTruck(truck); + } catch (Exception ex) { + msg = ex.getMessage(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } finally { + lock.unlock(); + } + + //判断请求是否成功 + Boolean bl = x != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", x); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + /** + * 删除我的板车信息 + * + * @return 返回是否删除成功 + */ + @RequestMapping("/delMyPalletTruck") + public String delMyPalletTruck() { + 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); + } + //有预约的时候不能删除车辆 或者修改个人信息(王琛) + if (userId != null && !userId.isEmpty()) { + Appointment myAppointment = appointmentService.getActiveAppointment(userId); + if (myAppointment != null) { + msg = "用户当前存在有效预约,不能删除板车信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + } + Integer x = mineService.deleteTruckByUsersId(userId); + //判断请求是否成功 + Boolean bl = x != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", x); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + /** + * 我的车辆黑名单信息 truck_management(该接口仅用于访问哪吒的接口) + * + * @return 返回我的车辆黑名单列表 + */ + @RequestMapping("/getMyTruckManagement") + public String getMyTruckManagement() { + 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); + } + List myTruckManagementList = mineService.getMyTruckManagement(userId); + //判断请求是否成功 + Boolean bl = myTruckManagementList != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("myTruckManagementList", myTruckManagementList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 提交反馈意见 feedback + * + * @param feedback:包含反馈意见的数据 + * @return 返回是否提交成功 + */ + @RequestMapping("/postFeedback") + public String postFeedback(Feedback feedback) { + CommonRes userInfoResCommonRes; + String userId; + String msg = ""; + try { + //请求哪吒接口获得用户信息 + userInfoResCommonRes = usersApi.getUserInfo(); + UserInfoRes userInfoRes = userInfoResCommonRes.getData(); + userId = userInfoRes.getId(); + feedback.setUsers_id(userId); + } catch (Exception ex) { + msg = "从rtos后台,获得用户信息异常," + ex.getMessage(); + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + Integer x = mineService.postFeedback(feedback); + //判断请求是否成功 + Boolean bl = x != null && x > 0; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", x); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + /** + * 我的预约信息列表 + * + * @return 我的预约信息列表 + */ + @RequestMapping("/getMyAppointmentList") + public String getMyAppointment() { + 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); + } + List myAppointmentList = mineService.getMyAppointmentList(userId); + //创建返回数据 + Integer code = (myAppointmentList != null) ? 200 : 0; + String message = (myAppointmentList != null) ? "request success" : "request fail"; + //判断请求是否成功 + Boolean bl = myAppointmentList != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("AppointmentList", myAppointmentList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 我的预约信息按日期查询分页列表 + *

+ * //@param users_id 司机id + * + * @param approach_date 预约进场时间 + * @param pages 页签实体 + * @return 返回我的预约信息分页数据 + */ + @RequestMapping("/getMyAppointmentListByDateForPage") + public String getMyAppointmentListByDate(@RequestParam("approach_date") String approach_date, Pages pages) { + 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); + } + //解析分页参数 + Integer pageNum = (pages != null && pages.getPageNum() != null && pages.getPageNum() > 0) ? pages.getPageNum() : 1; + Integer pageSize = (pages != null && pages.getPageSize() != null && pages.getPageSize() > 0) ? pages.getPageSize() : 10; + + //调用Service分页方法,获取分页数据对象 PageInfo + PageInfo pagesInfo = mineService.getMyAppointmentListByDateForPage(userId, approach_date, pageNum, pageSize); + //读取分页结果 + int pageCount = pagesInfo.getPages(); //总页数 + long recordTotal = pagesInfo.getTotal(); //记录总数 + List myList = pagesInfo.getList(); //当前页的列表数据 + //判断请求是否成功 + Boolean bl = myList != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("pageNum", pageNum); + data.put("pageCount", pageCount); + data.put("recordTotal", recordTotal); + data.put("dataJson", myList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 模糊查询我的预约信息,并按每页10条数据分页显示(作废) + *

+ * //@param users_id:司机用户id + * + * @param keywords:查询关键字 + * @param approach_date:查询日期 + * @return 模糊查询结果 getAppointmentDetailListForKeyWords + */ + @RequestMapping("/getMyAppointmentListForPage_old") + public String getMyAppointmentListForPage_old(@RequestParam("keywords") String keywords, + @RequestParam("approach_date") String approach_date, Pages pages) { + 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); + } + //解析分页参数 + Integer pageNum = (pages != null && pages.getPageNum() != null && pages.getPageNum() > 0) ? pages.getPageNum() : 1; + Integer pageSize = (pages != null && pages.getPageSize() != null && pages.getPageSize() > 0) ? pages.getPageSize() : 10; + //调用Service分页方法,获取分页数据对象 PageInfo + PageInfo pagesInfo = mineService.getMyAppointmentListForPage(userId, keywords, approach_date, pageNum, pageSize); + //读取分页结果 + int pageCount = pagesInfo.getPages(); //总页数 + long recordTotal = pagesInfo.getTotal(); //记录总数 + List myList = pagesInfo.getList(); //当前页的列表数据 + //判断请求是否成功 + Boolean bl = myList != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("pageNum", pageNum); + data.put("pageCount", pageCount); + data.put("recordTotal", recordTotal); + data.put("dataJson", myList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + @RequestMapping("/getMyAppointmentListForPage") + public String getMyAppointmentListForPage(@RequestParam("keywords") String keywords, + @RequestParam("approach_date") String approach_date, Pages pages) { + 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); + } + //解析分页参数 + Integer pageNum = (pages != null && pages.getPageNum() != null && pages.getPageNum() > 0) ? pages.getPageNum() : 1; + Integer pageSize = (pages != null && pages.getPageSize() != null && pages.getPageSize() > 0) ? pages.getPageSize() : 10; + //调用Service分页方法,获取分页数据对象 PageInfo + PageInfo pagesInfo = mineService.getMyAppointmentListForPageNew(userId, keywords, approach_date, pageNum, pageSize); + //读取分页结果 + int pageCount = pagesInfo.getPages(); //总页数 + long recordTotal = pagesInfo.getTotal(); //记录总数 + List myList = pagesInfo.getList(); //当前页的列表数据 + if (pages == null) { + pages = new Pages(); + } + pages.setPageNum(pageNum); + pages.setPageSize(pageSize); + pages.setPageCount(pageCount); + pages.setRecordTotal(recordTotal); + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("pages", pages); + data.put("list", myList); + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 新手攻略 + * + * @return 返回新手攻略 + */ + @RequestMapping("/getNoviceIntroduction") + public String getNoviceIntroduction(@RequestParam("sort") Integer sort) { + List noviceIntroductionList = mineService.getNoviceIntroduction(); + List mynoviceIntroductionList = Linq.of(noviceIntroductionList).where(p -> p.getSort() != null && p.getSort().equals(sort)).toList(); + //判断请求是否成功 + Boolean bl = noviceIntroductionList != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("NoviceIntroduction", mynoviceIntroductionList); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 我的打卡记录(查询指定日期,默认当天) + * + * @param my_date 指定日期 + * //@param users_id 司机id + * @return 返回我的打卡记录 + */ + @RequestMapping("/getPunchClockForDate") + public String getPunchClockForDate(@RequestParam("my_date") String my_date) { + 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); + } + LocalDate myDate = DateTimeHelper.DateStrToLocalDate(my_date); //LocalDate.parse(my_date); + //修改返回,未完工打卡, + List mylist = punchClockService.getPunchClockForDate(my_date, userId); + CurrentDayPunchClockDto currentDayPunchClockDto = new CurrentDayPunchClockDto(); + //总工时 + long totalWorkingSeconds = 0; + long totalWorkingHours = 0; + //打卡次数 + int totalPunchClockCount = 0; + if (mylist != null && mylist.size() > 0) { + for (PunchClock punchClock : mylist) { + String start_time = punchClock.getStart_time(); + String over_time = punchClock.getOver_time(); + //统计次数 + //if (start_time != null && !start_time.isEmpty()) { + // totalPunchClockCount = totalPunchClockCount + 1; + //} + //if (over_time != null && !over_time.isEmpty()) { + // totalPunchClockCount = totalPunchClockCount + 1; + //} + if ((start_time != null && !start_time.isEmpty()) || (over_time != null && !over_time.isEmpty())) { + totalPunchClockCount = totalPunchClockCount + 1; + } + //计算签到打卡时间与完成打卡时间的时间差(单位秒数) + long timechaSeconds = FormatDateTime.getTimeCha(start_time, over_time); + //统计工时 + if (timechaSeconds > 0) { + //累加打卡的工时 + totalWorkingSeconds = totalWorkingSeconds + timechaSeconds; + } + } + } + //将总秒数转化为总小时数据 + totalWorkingHours = TimeUnit.MILLISECONDS.toHours(totalWorkingSeconds); + currentDayPunchClockDto.setPunchClockList(mylist); + currentDayPunchClockDto.setTotalPunchClockCount(totalPunchClockCount); + currentDayPunchClockDto.setTotalWorkingHours(totalWorkingHours); + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("CurrentDayPunchClock", currentDayPunchClockDto); + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + + } + + /** + * 我的打卡记录(查询指定司机某年某月的打卡记录) + * + * @param year 年 + * @param month 月 + * //@param users_id 司机id + * @return 返回我的打卡记录 + */ + @RequestMapping("/getPunchClockForYM") + public String getPunchClockForYM(@RequestParam("year") Integer year, @RequestParam("month") Integer month) { + 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); + } + List mylist = punchClockService.getPunchClockForYM(year, month, userId); + List myappointmentList = mineService.getMyAppointmentList(userId); + //找到对应的预约进港时间 (王琛需要) + //未完成的预约进港日期 + List approachDateList_ww = new ArrayList<>(); + //已完成的预约进港日期 + List approachDateList_yw = new ArrayList<>(); + //查出未完成的预约进港日期 + List mylist1 = null; + if (mylist != null && mylist.size() > 0) { + //查询当月未完工打卡的记录() + //mylist1 = Linq.of(mylist).where(p -> p.getPunch_clock_type() < 4).toList(); + mylist1 = Linq.of(mylist).where(p -> p.getPunch_clock_type().compareTo(4) < 0).toList(); + List appointmentIdList1; + if (mylist1 != null && mylist1.size() > 0) { + appointmentIdList1 = Linq.of(mylist1).select(PunchClock::getAppointment_id).toList(); + if (appointmentIdList1 != null && appointmentIdList1.size() > 0) { + if (myappointmentList != null && myappointmentList.size() > 0) { + //未完成的 + List myappointmentList1 = Linq.of(myappointmentList).where(o -> appointmentIdList1.contains(o.getId())).toList(); + if (myappointmentList1 != null && myappointmentList1.size() > 0) { + approachDateList_ww = Linq.of(myappointmentList1).select(Appointment::getApproach_date).distinct().toList(); + } + } + } + } + } + //查出已完成的预约进港日期 + List mylist2 = null; + if (mylist != null && mylist.size() > 0) { + //查询当月未完工打卡的记录(不关心预约是否取消) + //mylist2 = Linq.of(mylist).where(p -> p.getPunch_clock_type() >= 4).toList(); + mylist2 = Linq.of(mylist).where(p -> !(p.getPunch_clock_type().compareTo(4) < 0)).toList(); + List appointmentIdList2; + if (mylist2 != null && mylist2.size() > 0) { + appointmentIdList2 = Linq.of(mylist2).select(PunchClock::getAppointment_id).toList(); + if (appointmentIdList2 != null && appointmentIdList2.size() > 0) { + if (myappointmentList != null && myappointmentList.size() > 0) { + //已完成的 + List myappointmentList2 = Linq.of(myappointmentList).where(o -> appointmentIdList2.contains(o.getId())).toList(); + if (myappointmentList2 != null && myappointmentList2.size() > 0) { + approachDateList_yw = Linq.of(myappointmentList2).select(Appointment::getApproach_date).distinct().toList(); + List finalApproachDateList_ww = approachDateList_ww; + approachDateList_yw = Linq.of(approachDateList_yw).where(o -> !finalApproachDateList_ww.contains(o)).toList(); + } + } + } + } + } + //获得打卡记录的预约信息 + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("approachDateList_ww", approachDateList_ww); + data.put("approachDateList_yw", approachDateList_yw); + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 获取当前排队前面还剩多少车辆未进港 + * @return 返回我前面的排队待进港的车辆数 + */ + @RequestMapping("/getNumberBeforeMe") + public String getNumberBeforeMe() { + 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); + } + //-1-首先查找我的当前预约 + Appointment myAppointment = mineService.getMyAppointment(userId); + if (myAppointment == null) { + msg = "不存在用户Id" + userId + "的预约"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + //-2-读取预约关键数据 + String appointment_id = myAppointment.getId(); + String port_area_id = myAppointment.getPort_area_id(); + //LocalDate approach_date = LocalDate.parse(myAppointment.getApproach_date()); + String approach_date = myAppointment.getApproach_date(); + + //-3-获取预约排队编号 + String queueNumber = punchClockService.getQueueNumber(appointment_id); + String queue_number = (queueNumber.isEmpty()) ? queueNumber : null; + + //-4-获取当前排队前面还剩多少车辆未进港(条件:相同的进港日期和进港港区、且尚未进港的车辆数量中,排队编号比我小的车辆数量 + Integer x = (queue_number != null) ? punchClockService.getNumberBefore(approach_date, port_area_id, queue_number) : null; + + //判断请求是否成功 + Boolean bl = x != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("number_before_me", x); + //返回 + return response.getResponseData(bl, data); + } + + /** + * 获取我的排队号 + * + * //@param users_id 用户id + * @return 获取我的排队号 + */ + @RequestMapping("/getNumberForMe") + public String getNumberForMe() { + 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); + } + //-1-首先查找我的当前预约 + Appointment myAppointment = mineService.getMyAppointment(userId); + if (myAppointment == null) { + msg = "不存在用户Id" + userId + "的预约"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //返回 + return response.getResponseData(bl, data, msg); + } + //-2-读取预约关键数据 + String appointment_id = myAppointment.getId(); + //-3-获取预约排队编号 + String queueNumber = punchClockService.getQueueNumber(appointment_id); + //判断请求是否成功 + Boolean bl = queueNumber != null && !queueNumber.isEmpty(); + //创建返回数据 + Map data = new HashMap<>(); + data.put("queueNumber", queueNumber); + //返回 + return response.getResponseData(bl, data); + } + + /** + * RTOS提交黑名单车辆 + * + * @param truck_number 车牌号 + * @return 返回提交黑名单车辆执行结果 + */ + @RequestMapping("/postTruckBlacklist") + public String postTruckBlacklist(@RequestParam("truck_number") String truck_number) { + //此处接收哪吒rtos提交的黑名单车辆信息数据,更新到板车数据表,并发送一条的消息。 + return ""; + } + + /** + * //弃用 + * + * @param userTrucks + * @return + */ + @PostMapping("/execUserTruck") + public String execUserTruck(@RequestBody List userTrucks) { + com.haitongauto.models.res.Response myResponse = new com.haitongauto.models.res.Response(); + String msg = ""; + try { + Integer res = forwardService.execUserTruck(userTrucks); + myResponse.setCode(200); + } catch (Exception ex) { + myResponse.setCode(500); + myResponse.setMsg(ex.getMessage()); + } + return myResponse.toJSONString(); + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/NewsController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/NewsController.java new file mode 100644 index 0000000..1625cbe --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/NewsController.java @@ -0,0 +1,358 @@ +package com.haitongauto.rtosac.api; + +import com.alibaba.fastjson.JSON; +import com.haitongauto.mapper.base.PunchClockMapper; +import com.haitongauto.models.pojo.*; +import com.haitongauto.rtosac.service.*; +import com.haitongauto.models.dto.DataForMessage; +import com.haitongauto.utils.DateTimeHelper; +import com.haitongauto.utils.FormatDateTime; +import com.haitongauto.utils.QueueNumberHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 指令消息 + */ +@RestController +@RequestMapping("/news") +public class NewsController { + @Autowired + NewsService newsService; + @Autowired + HomeService homePageService; + @Autowired + Response response; + @Autowired + AppointmentService appointmentService; + @Autowired + PunchClockService punchClockService; + @Autowired + HomeService homeService; + + + /** + * RTOS向小程序提交车辆过闸信息(正常过闸) + * + * @param pass_type:车辆过闸类型,1-进闸,2-出闸 + * @param truck_number:板车号 + * @param gate_canal:道口号 + * @return 返回提交结果 + */ + @RequestMapping("/sendTruckThroughGateInfo") + public String sendTruckThroughGateInfo(@RequestParam("pass_type") Integer pass_type, + @RequestParam("truck_number") String truck_number, + @RequestParam("gate_canal") String gate_canal) { + String msg = ""; + if (pass_type == null || pass_type.equals(0)) { + msg = "车辆过闸类型,不能为空,1-进闸,2-出闸"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = msg; + data.put("message", message); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + if (truck_number == null) { + msg = "板车号不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = msg; + data.put("message", message); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + Appointment appointment = null; + if (pass_type.equals(1)) { + appointment = appointmentService.getAppointmentByTruckNo(truck_number); + } else if (pass_type.equals(2)) { + appointment = appointmentService.getAppointmentByTruckNoForOutGate(truck_number); + } + + if (appointment == null) { + msg = "板车号" + truck_number + "当前不存在有效预约"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = msg; + data.put("message", message); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + Date date = new Date(); + //进闸口 + if (pass_type.equals(1)) { + appointment.setIs_conventionality_in(0);//正常自动过闸口 + appointment.setGate_canal_in(gate_canal); + //签到打卡时间 + if (appointment.getCheck_in_time() == null || appointment.getCheck_in_time().isEmpty()) { + appointment.setCheck_in_time(FormatDateTime.dateTimeToStr(date)); + } + //进闸口时间 + appointment.setGate_canal_in_time(FormatDateTime.dateTimeToStr(date)); + } else if (pass_type.equals(2)) {//出闸口 + appointment.setGate_canal_out(gate_canal); + //完工打卡时间 + if (appointment.getCheck_over_time() == null || appointment.getCheck_over_time().isEmpty()) { + appointment.setCheck_over_time(FormatDateTime.dateTimeToStr(date)); + } + //出闸口时间 + appointment.setGate_canal_out_time(FormatDateTime.dateTimeToStr(date)); + } + //定义该车牌用户的当前预约打卡状态 + Integer appointment_state = (pass_type.equals(1)) ? 3 : 7; //3-进港,7-离港 + Integer punch_clock_type = (pass_type.equals(1)) ? 2 : 5; //2-已进港,5-已离港 + //更新预约状态 + + appointment.setAppointment_state(appointment_state); + appointment.setUpdate_time(FormatDateTime.dateTimeToStr(new Date())); + Integer x = appointmentService.updateAppointment(appointment); + //更新打卡状态 + if (x > 0) { + String appointment_id = appointment.getId(); + PunchClock punchClock = punchClockService.getPunchClockForAppintementId(appointment_id); + if (punchClock != null) { + punchClock.setPunch_clock_type(punch_clock_type); + //进闸口 + if (pass_type == 1) { + //如果未打签到卡,则打签到卡; + String start_time = punchClock.getStart_time(); + if (start_time == null || start_time.isEmpty()) { + punchClock.setStart_time(FormatDateTime.dateTimeToStr(date)); + } + //生成新的排队编号 + //排队号需求变更,格式"2308210001" + String queue_number = punchClock.getQueue_number(); + if (queue_number == null || queue_number.isEmpty()) { + //获取当前日期最后一个排队编号 + String last_queue_number = punchClockService.getLastQueueNumber(date, appointment.getPort_area_id()); + queue_number = QueueNumberHelper.getNewQueueNumber(last_queue_number); + punchClock.setQueue_number(queue_number); + } + //签到打卡地点 + String punch_address = punchClock.getPunch_address(); + if (punch_address == null || punch_address.isEmpty()) { + PortArea portArea = punchClockService.getPortAreaForId(appointment.getPort_area_id()); + if (portArea != null) { + punchClock.setPunch_address(portArea.getPort_area_address()); + } + } + } else {//出闸口 + //完工打卡时间 + String over_time = punchClock.getOver_time(); + if (over_time == null || over_time.isEmpty()) { + punchClock.setOver_time(FormatDateTime.dateTimeToStr(date)); + } + //完工打卡地点 + String over_address = punchClock.getOver_address(); + if (over_address == null || over_address.isEmpty()) { + PortArea portArea = punchClockService.getPortAreaForId(appointment.getPort_area_id()); + if (portArea != null) { + punchClock.setOver_address(portArea.getPort_area_address()); + } + } + } + punchClock.setUpdate_time(FormatDateTime.dateTimeToStr(new Date())); + int myx = punchClockService.updatePunchClock(punchClock); + } + } + if (pass_type.equals(1)) { + msg = "板车" + truck_number + "进闸成功"; + } + if (pass_type.equals(1)) { + msg = "板车" + truck_number + "出闸成功"; + } + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = (bl) ? "request success" : "request fail"; + data.put("message", message); + if (bl) { + data.put("code", "200"); + } + + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + + } + + /** + * RTOS向小程序提交车辆过闸信息(人工过闸) + * + * @param pass_type:车辆过闸类型,1-进闸,2-出闸 + * @param truck_number:板车号 + * @param gate_canal:道口号 + * @return 返回提交结果 + */ + @RequestMapping("/sendTruckThroughGateInfoUnconventionality") + public String sendTruckThroughGateInfoUnconventionality(@RequestParam("pass_type") Integer pass_type, + @RequestParam("truck_number") String truck_number, + @RequestParam("gate_canal") String gate_canal) { + String msg = ""; + if (pass_type == null || pass_type.equals(0)) { + msg = "车辆过闸类型,不能为空,1-进闸,2-出闸"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = msg; + data.put("message", message); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + if (truck_number == null) { + msg = "板车号不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = msg; + data.put("message", message); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + Appointment appointment = null; + if (pass_type.equals(1)) { + appointment = appointmentService.getAppointmentByTruckNo(truck_number); + } else if (pass_type.equals(2)) { + appointment = appointmentService.getAppointmentByTruckNoForOutGate(truck_number); + } + if (appointment == null) { + msg = "板车号" + truck_number + "当前不存在有效预约"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = msg; + data.put("message", message); + //返回 + return response.getResponseData(bl, data, msg); + } + + Date date = new Date(); + //进闸口 + if (pass_type.equals(1)) { + appointment.setIs_conventionality_in(1);//非正常的过闸口 + appointment.setGate_canal_in(gate_canal); + //签到打卡时间 + if (appointment.getCheck_in_time() == null || appointment.getCheck_in_time().isEmpty()) { + appointment.setCheck_in_time(FormatDateTime.dateTimeToStr(date)); + } + //进闸口时间 + appointment.setGate_canal_in_time(FormatDateTime.dateTimeToStr(date)); + } else if (pass_type.equals(2)) {//出闸口 + appointment.setGate_canal_out(gate_canal); + //完工打卡时间 + if (appointment.getCheck_over_time() == null || appointment.getCheck_over_time().isEmpty()) { + appointment.setCheck_over_time(FormatDateTime.dateTimeToStr(date)); + } + //出闸口时间 + appointment.setGate_canal_out_time(FormatDateTime.dateTimeToStr(date)); + } + + //定义该车牌用户的当前预约打卡状态 + Integer appointment_state = (pass_type.equals(1)) ? 3 : 7; //3-进港,7-离港 + Integer punch_clock_type = (pass_type.equals(1)) ? 2 : 5; //2-已进港,5-已离港 + //更新预约状态 + + appointment.setAppointment_state(appointment_state); + appointment.setUpdate_time(FormatDateTime.dateTimeToStr(new Date())); + Integer x = appointmentService.updateAppointment(appointment); + //更新打卡状态 + if (x > 0) { + String appointment_id = appointment.getId(); + PunchClock punchClock = punchClockService.getPunchClockForAppintementId(appointment_id); + if (punchClock != null) { + punchClock.setPunch_clock_type(punch_clock_type); + //进闸口 + if (pass_type == 1) { + //如果未打签到卡,则打签到卡; + String start_time = punchClock.getStart_time(); + if (start_time == null || start_time.isEmpty()) { + punchClock.setStart_time(FormatDateTime.dateTimeToStr(date)); + } + //生成新的排队编号 + //排队号需求变更,格式"2308210001" + String queue_number = punchClock.getQueue_number(); + if (queue_number == null || queue_number.isEmpty()) { + //获取当前日期最后一个排队编号 + String last_queue_number = punchClockService.getLastQueueNumber(date, appointment.getPort_area_id()); + queue_number = QueueNumberHelper.getNewQueueNumber(last_queue_number); + punchClock.setQueue_number(queue_number); + } + //签到打卡地点 + String punch_address = punchClock.getPunch_address(); + if (punch_address == null || punch_address.isEmpty()) { + PortArea portArea = punchClockService.getPortAreaForId(appointment.getPort_area_id()); + if (portArea != null) { + punchClock.setPunch_address(portArea.getPort_area_address()); + } + } + } else {//出闸口 + //完工打卡时间 + String over_time = punchClock.getOver_time(); + if (over_time == null || over_time.isEmpty()) { + punchClock.setOver_time(FormatDateTime.dateTimeToStr(date)); + } + //完工打卡地点 + String over_address = punchClock.getOver_address(); + if (over_address == null || over_address.isEmpty()) { + PortArea portArea = punchClockService.getPortAreaForId(appointment.getPort_area_id()); + if (portArea != null) { + punchClock.setOver_address(portArea.getPort_area_address()); + } + } + } + punchClock.setUpdate_time(FormatDateTime.dateTimeToStr(new Date())); + int myx = punchClockService.updatePunchClock(punchClock); + } + } + + if (pass_type.equals(1)) { + msg = "板车" + truck_number + "进闸成功"; + } else if (pass_type.equals(2)) { + msg = "板车" + truck_number + "出闸成功"; + } + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("result", bl); + String message = (bl) ? "request success" : "request fail"; + data.put("message", message); + if (bl) { + data.put("code", "200"); + } + //返回 + return response.getResponseData(bl, data, msg); + + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/PunchClockController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/PunchClockController.java new file mode 100644 index 0000000..7796420 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/PunchClockController.java @@ -0,0 +1,667 @@ +package com.haitongauto.rtosac.api; + +import com.bestvike.linq.Linq; +import com.haitongauto.interfaces.UsersApi; +import com.haitongauto.models.dto.CurrentDayPunchClockDto; +import com.haitongauto.models.ido.CommonRes; +import com.haitongauto.models.ido.login.UserInfoRes; +import com.haitongauto.models.pojo.*; +import com.haitongauto.rtosac.service.*; +import com.haitongauto.utils.DateTimeHelper; +import com.haitongauto.utils.FormatDateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * 打卡操作 + */ +@RestController +@RequestMapping("/punchclock") +public class PunchClockController { + @Autowired + AppointmentService appointmentService; + @Autowired + PunchClockService punchClockService; + @Autowired + VehicleService vehicleService; + @Autowired + MineService mineService; + + @Resource + private UsersApi usersApi; + + @Autowired + Response response; + + /** + * 检查是否有未完成预约 + * + * //@param users_id 用户id + * @return 返回完成预约 + */ + @RequestMapping("/getIincompleteAppointment") + public String getIincompleteAppointment() { + 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); + } + //获取未完成预约 + Appointment appointment = punchClockService.getIincompleteAppointment(userId); + String appointment_id = (appointment != null) ? appointment.getId() : null; + //获取该预约的打卡信息 + PunchClock mypunchClock = (appointment_id != null) ? punchClockService.getPunchClockForAppintementId(appointment_id) : null; + + //读取打卡的时间和地址信息 + Integer appointment_type = (appointment != null) ? appointment.getAppointment_type() : null; + String punch_start_time = (mypunchClock != null) ? mypunchClock.getStart_time() : ""; + String punch_over_time = (mypunchClock != null) ? mypunchClock.getOver_time() : ""; + String punch_start_address = (mypunchClock != null) ? mypunchClock.getPunch_address() : ""; + String punch_over_address = (mypunchClock != null) ? mypunchClock.getOver_address() : ""; + + //读取进港港区Id + String port_area_id = (appointment != null) ? appointment.getPort_area_id() : null; + //进港港区信息 + PortArea portArea = punchClockService.getPortAreaForId(port_area_id); + //进港港区中心坐标 + String poi = (portArea != null) ? portArea.getArea_center_poi() : ""; + //打卡范围 + Integer punch_range = (portArea != null && portArea.getPunch_range() != null) ? portArea.getPunch_range() : 0; + //判断请求是否成功 + Boolean bl = true; + //创建返回数据对象 + Map data = new HashMap<>(); + data.put("appointment_type", appointment_type); + data.put("poi", poi); + data.put("punch_range", punch_range); + 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("appointment", appointment); + //封装数据 + return response.getResponseData(bl, data); + } + + /** + * 签到打卡提交 + * + * //@param users_id 用户id + * @param appointment_id 预约id + * @param port_area_id 港区id + * @param punch_poi 坐标 + * @return 返回提交结果 + */ + @RequestMapping("/postPunchClockStart") + public String postPunchClockStart(@RequestParam("appointment_id") String appointment_id, + @RequestParam("port_area_id") String port_area_id, + @RequestParam("punch_poi") String punch_poi, + @RequestParam("punch_address") String punch_address) { + 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); + } + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + if (port_area_id == null || port_area_id.isEmpty()) { + msg = "港区Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + if (punch_poi == null || punch_poi.isEmpty()) { + msg = "坐标不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + if (punch_address == null || punch_address.isEmpty()) { + msg = "打卡地点不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + + //写入打卡数据 + PunchClock punchClock = punchClockService.postPunchClockStart(userId, appointment_id, port_area_id, punch_poi, punch_address); + String punch_clock_id = ""; + String queue_number = ""; + String punch_date_time = ""; + if (punchClock == null) { + msg = "不在该预约信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + + } else { + punch_clock_id = punchClock.getId(); + queue_number = punchClock.getQueue_number(); + //获取签到打卡的日期时间(年月日小时分钟秒) + //转换为两位数格式字符串 + String punch_date = punchClock.getStart_time().split(" ")[0]; + String punch_time = punchClock.getStart_time().split(" ")[1]; + punch_date_time = punch_date + " " + punch_time; + } + + Appointment appointment = appointmentService.getAppointmentById(appointment_id); + Integer x = null; + if (queue_number != null && !queue_number.isEmpty() && appointment != null) { + //获取当前排队前面还剩多少位 + x = punchClockService.getNumberBefore(appointment.getApproach_date(), appointment.getPort_area_id(), queue_number); + } + + //判断请求是否成功 + Boolean bl = punch_clock_id != null && !punch_clock_id.isEmpty(); + //创建返回数据 + Map data = new HashMap<>(); + data.put("punch_clock_id", punch_clock_id); + data.put("NumberBeforeCount", x); + data.put("queue_number", queue_number); + data.put("punch_time", punch_date_time); + data.put("punch_address", punch_address); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + + /** + * 完成打卡提交 + * + * @param appointment_id 预约id + * @param punch_clock_id 打卡id + * @return 返回完成打卡提交执行结果 + */ + @RequestMapping("/postPunchClockOver") + public String postPunchClockOver(@RequestParam("appointment_id") String appointment_id, + @RequestParam("punch_clock_id") String punch_clock_id, + @RequestParam("punch_address") String punch_address) { + //打卡信息更新到数据库 + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } +// if (punch_clock_id == null || punch_clock_id.isEmpty()) { +// msg = "预约打卡记录id不能为空"; +// //判断请求是否成功 +// Boolean bl = false; +// //创建返回数据 +// Map data = new HashMap<>(); +// //封装数据 +// return response.getResponseData(bl, data, msg); +// } + if (punch_address == null || punch_address.isEmpty()) { + msg = "打卡地点不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + Appointment myAppointment = appointmentService.getAppointmentById(appointment_id); + PunchClock myPunchClock = punchClockService.getPunchClockForAppintementId(appointment_id); + if (myAppointment == null) { + msg = "不存预约Id为" + appointment_id + "的预约信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + if (myPunchClock == null) { + msg = "不存预约Id为" + appointment_id + "的打卡记录信息"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + + PunchClock punchClock = punchClockService.postPunchClockOver(appointment_id, punch_clock_id, punch_address); + //获取签到打卡的日期时间(年月日小时分钟秒) + String punch_date = ""; + String punch_time = ""; + String punch_date_time = ""; + if (punchClock != null) { + String[] strArray = punchClock.getOver_time().split(" "); + //转换为两位数格式字符串 + punch_date = strArray[0]; + punch_time = strArray[1]; + punch_date_time = punch_date + " " + punch_time; + } + //注意:此处还需追加完成打卡后生成指令,并提交到哪吒接口 + + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("punch_time", punch_date_time); + data.put("punch_address", punch_address); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + /** + * 根据预约Id获取打卡记录状态 + * @param appointment_id 预约id + * @return 返回打卡记录 + */ + @RequestMapping("getPunchState") + public String getPunchState(@RequestParam("appointment_id") String appointment_id) { + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + //获取指定预约的打卡记录 + PunchClock punchClock = punchClockService.getPunchClockForAppintementId(appointment_id); + if (punchClock == null) { + msg = "不存在预约Id为" + appointment_id + "的打卡记录"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + //读取该预约的打卡状态 + Integer punch_clock_type = punchClock.getPunch_clock_type(); + //判断请求是否成功 + Boolean bl = punch_clock_type != null && punch_clock_type > 0; + //创建返回数据 + Map data = new HashMap<>(); + data.put("appointment_id", appointment_id); + data.put("punch_clock_type", punch_clock_type); + //封装数据 + //返回 + return response.getResponseData(bl, data); + + } + + /** + * 我的打卡记录(查询指定日期,默认当天) + * + * @param my_date 指定日期 + * //@param users_id 司机id + * @return 返回我的打卡记录 + */ + @RequestMapping("/getPunchClockForDate") + public String getPunchClockForDate(@RequestParam("my_date") String my_date) { + 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 (my_date == null || my_date.isEmpty()) { + msg = "指定日期不能为空"; + //判断请求是否成功 + 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); + } + LocalDate myDate = DateTimeHelper.DateStrToLocalDate(my_date); + List mylist = punchClockService.getPunchClockForDate(my_date, userId); + CurrentDayPunchClockDto currentDayPunchClockDto = new CurrentDayPunchClockDto(); + //总工时 + long totalWorkingSeconds = 0;//秒 + //long totalWorkingHours = 0;//小时 + double totalWorkingHours = 0;//小时 + //打卡次数 + int totalPunchClockCount = 0; + if (mylist != null && mylist.size() > 0) { + for (PunchClock punchClock : mylist) { + String start_time = punchClock.getStart_time(); + String over_time = punchClock.getOver_time(); + //统计次数 + //if (start_time != null && !start_time.isEmpty()) { + // totalPunchClockCount = totalPunchClockCount + 1; + //} + //if (over_time != null && !over_time.isEmpty()) { + // totalPunchClockCount = totalPunchClockCount + 1; + //} + + //签到打卡统计,累加次数 + if (start_time != null && !start_time.isEmpty() ) { + totalPunchClockCount = totalPunchClockCount + 1; + } + //完工打卡打卡统计,累加次数 + if (over_time != null && !over_time.isEmpty() ) { + totalPunchClockCount = totalPunchClockCount + 1; + } + + //计算签到打卡时间与完成打卡时间的时间差(单位秒数) + long timechaSeconds = FormatDateTime.getTimeCha(start_time, over_time); + //统计工时 + if (timechaSeconds > 0) { + //累加打卡的工时 + totalWorkingSeconds = totalWorkingSeconds + timechaSeconds; + } + } + } + //将总秒数转化为总小时数据 + if (totalWorkingSeconds > 0) { + //totalWorkingHours = TimeUnit.MILLISECONDS.toHours(totalWorkingSeconds); + totalWorkingHours = (double) totalWorkingSeconds / 3600; + //小时数据保留四位小数 + totalWorkingHours = Math.round(totalWorkingHours * 10000) / 10000.0; + } + currentDayPunchClockDto.setPunchClockList(mylist); + currentDayPunchClockDto.setTotalPunchClockCount(totalPunchClockCount); + currentDayPunchClockDto.setTotalWorkingHours(totalWorkingHours); + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("CurrentDayPunchClock", currentDayPunchClockDto); + //封装数据 + return response.getResponseDataJavaJson(bl, data); + + } + + + /** + * 我的打卡记录(查询指定司机某年某月的打卡记录) + * + * @param year 年 + * @param month 月 + * //@param users_id 司机id + * @return 返回我的打卡记录 + */ + @RequestMapping("/getPunchClockForYM") + public String getPunchClockForYM(@RequestParam("year") Integer year, + @RequestParam("month") Integer month) { + 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); + } + List mylist = punchClockService.getPunchClockForYM(year, month, userId); + List myappointmentList = mineService.getMyAppointmentList(userId); + //找到对应的预约进港时间 (王琛需要) + //未完成的预约进港日期 + List approachDateList_ww = new ArrayList<>(); + //已完成的预约进港日期 + List approachDateList_yw = new ArrayList<>(); + //查出未完成的预约进港日期 + List mylist1 = null; + if (mylist != null && mylist.size() > 0) { + //查询当月未完工打卡的记录() + //mylist1 = Linq.of(mylist).where(p -> p.getPunch_clock_type() < 4).toList(); + mylist1 = Linq.of(mylist).where(p -> p.getPunch_clock_type().compareTo(4) < 0).toList(); + List appointmentIdList1; + if (mylist1 != null && mylist1.size() > 0) { + appointmentIdList1 = Linq.of(mylist1).select(PunchClock::getAppointment_id).toList(); + if (appointmentIdList1 != null && appointmentIdList1.size() > 0) { + if (myappointmentList != null && myappointmentList.size() > 0) { + //未完成的 + List myappointmentList1 = Linq.of(myappointmentList).where(o -> appointmentIdList1.contains(o.getId())).toList(); + if (myappointmentList1 != null && myappointmentList1.size() > 0) { + approachDateList_ww = Linq.of(myappointmentList1).select(Appointment::getApproach_date).distinct().toList(); + } + } + } + } + } + //查出已完成的预约进港日期 + List mylist2 = null; + if (mylist != null && mylist.size() > 0) { + //查询当月未完工打卡的记录(不关心预约是否取消) + //mylist2 = Linq.of(mylist).where(p -> p.getPunch_clock_type() >= 4).toList(); + mylist2 = Linq.of(mylist).where(p -> !(p.getPunch_clock_type().compareTo(4) < 0)).toList(); + List appointmentIdList2; + if (mylist2 != null && mylist2.size() > 0) { + appointmentIdList2 = Linq.of(mylist2).select(PunchClock::getAppointment_id).toList(); + if (appointmentIdList2 != null && appointmentIdList2.size() > 0) { + if (myappointmentList != null && myappointmentList.size() > 0) { + //已完成的 + List myappointmentList2 = Linq.of(myappointmentList).where(o -> appointmentIdList2.contains(o.getId())).toList(); + if (myappointmentList2 != null && myappointmentList2.size() > 0) { + approachDateList_yw = Linq.of(myappointmentList2).select(Appointment::getApproach_date).distinct().toList(); + List finalApproachDateList_ww = approachDateList_ww; + approachDateList_yw = Linq.of(approachDateList_yw).where(o -> !finalApproachDateList_ww.contains(o)).toList(); + } + } + } + } + } + //获得打卡记录的预约信息 + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("approachDateList_ww", approachDateList_ww); + data.put("approachDateList_yw", approachDateList_yw); + return response.getResponseDataJavaJson(bl, data); + } + + + /** + * 获取港区中心点坐标 + * + * @param port_area_id 港区id + * @return 返回港区中心坐标 + */ + @RequestMapping("/getPortAreaPoi") + public String getPortAreaPoi(@RequestParam("port_area_id") String port_area_id) { + String msg = ""; + if (port_area_id == null || port_area_id.isEmpty()) { + msg = "港区Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + String poi = punchClockService.getPortAreaPoi(port_area_id); + //判断请求是否成功 + Boolean bl = poi != null && !poi.isEmpty(); + //创建返回数据 + Map data = new HashMap<>(); + data.put("poi", poi); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + /** + * 获取排队编号 + * + * @param appointment_id : 预约编号 + * @return 返回排队编号 + */ + @RequestMapping("/getQueueNumber") + public String getQueueNumber(@RequestParam("appointment_id") String appointment_id) { + String msg = ""; + if (appointment_id == null || appointment_id.isEmpty()) { + msg = "预约Id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + String queue_number = punchClockService.getQueueNumber(appointment_id); + Appointment appointment = appointmentService.getAppointmentById(appointment_id); + + Integer x = null; + if (queue_number != null && !queue_number.isEmpty() && appointment != null) { + x = punchClockService.getNumberBefore(appointment.getApproach_date(), appointment.getPort_area_id(), queue_number); + } + + //判断请求是否成功 + Boolean bl = true; + //创建返回数据 + Map data = new HashMap<>(); + data.put("NumberBeforeCount", x); + data.put("queue_number", queue_number); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + + + /** + * 获取用户排队时前面还剩余多少位 + * + * @param approach_date:预约日期 + * @param port_area_id:进港港区 + * @param queue_number:排队编号 + * @return 返回结果 + */ + @RequestMapping("/getNumberBefore") + public String getNumberBefore(@RequestParam("approach_date") String approach_date, @RequestParam("port_area_id") String port_area_id, @RequestParam("queue_number") String queue_number) { + Integer x = punchClockService.getNumberBefore(approach_date, port_area_id, queue_number); + //判断请求是否成功 + Boolean bl = x != null; + //创建返回数据 + Map data = new HashMap<>(); + data.put("NumberBeforeCount", x); + data.put("queue_number", queue_number); + //封装数据 + //返回 + return response.getResponseData(bl, data); + } + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/VehicleController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/VehicleController.java new file mode 100644 index 0000000..dfb4428 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/VehicleController.java @@ -0,0 +1,370 @@ +package com.haitongauto.rtosac.api; + +import com.haitongauto.interfaces.OrderApi; +import com.haitongauto.interfaces.UsersApi; +import com.haitongauto.models.ido.CheckRes; +import com.haitongauto.models.ido.CommonRes; +import com.haitongauto.models.ido.departure.DepartureDetailIdo; +import com.haitongauto.models.ido.departure.DepartureDetailIdo_DTO; +import com.haitongauto.models.ido.departure.DepartureVehicleIdo; +import com.haitongauto.models.ido.departure.DepartureVehicleIdo_DTO; +import com.haitongauto.models.ido.receiving.ReceivingDetailIdo; +import com.haitongauto.models.ido.receiving.ReceivingDetailIdo_DTO; +import com.haitongauto.models.ido.receiving.ReceivingVehicleIdo; +import com.haitongauto.models.ido.receiving.ReceivingVehicleIdo_DTO; +import com.haitongauto.models.pojo.Appointment; +import com.haitongauto.models.pojo.PunchClock; +import com.haitongauto.rtosac.service.AppointmentService; +import com.haitongauto.rtosac.service.PunchClockService; +import com.haitongauto.rtosac.service.Response; +import com.haitongauto.rtosac.service.VehicleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.*; + +@RestController +@RequestMapping("/vehicle") +public class VehicleController { + @Autowired + VehicleService vehicleService; + @Autowired + Response response; + @Autowired + AppointmentService appointmentService; + @Autowired + PunchClockService punchClockService; + @Resource + OrderApi orderApi; + @Resource + private UsersApi usersApi; + + /** + * 获取收车凭证的分页数据(从Rtos请求数据) + *

+ * //@param users_id 当前页码 + * + * @return 返回收车凭证的分页数据 + */ + @GetMapping("/getVehicleReceivingList") + public String getVehicleReceivingList(@RequestParam("printTicketTime") String printTicketTime, + @RequestParam("query") String query, + @RequestParam("pageNum") Integer pageNum, + @RequestParam("pageSize") Integer pageSize) { + //解析分页参数 + pageNum = (pageNum != null && pageNum > 0) ? pageNum : 1; + pageSize = (pageSize != null && pageSize > 0) ? pageSize : 10; + List myList = null; + + //通过RTOS接口读取收车凭证分页数据 + ReceivingVehicleIdo_DTO receivingVehicleIdo_dto = vehicleService.getVehicleReceivingList(printTicketTime, query, pageNum, pageSize); //当前页的列表数据 + String status = receivingVehicleIdo_dto.getStatus(); + //用户权限过期 + if ("401".equals(status)) { + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getRtosResponseData(bl, data, "401"); + } + + if ("200".equals(status)) { + myList = receivingVehicleIdo_dto.getReceivingVehicleIdoList(); + } + //判断请求是否成功 + Boolean bl = "200".equals(status); + //创建返回数据对象 + Map data = new HashMap<>(); + data.put("pageNum", pageNum); + if (myList != null && myList.size() > 0) { + //data.put("pageSize", pageSize); + data.put("pageSize", myList.size()); + data.put("ReceivingVehicleIdoList", myList); + } else { + data.put("pageSize", 0); + data.put("ReceivingVehicleIdoList", null); + } + //封装数据 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 收车凭证详细信息(从Rtos请求数据) + * + * @param vehicle_receiving_id:收车id + * @return 返回收车凭证详细信息 + */ + @GetMapping("/getVehicleReceivingInfo") + public String getVehicleReceivingInfo(@RequestParam("vehicle_receiving_id") String vehicle_receiving_id) { + String msg = ""; + if (vehicle_receiving_id == null || vehicle_receiving_id.isEmpty()) { + msg = "收车凭证id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + //外部接口获取凭证数据 + ReceivingDetailIdo receivingDetailIdo = null; + ReceivingDetailIdo_DTO receivingDetailIdo_dto = vehicleService.getVehicleReceivingInfo(vehicle_receiving_id); + String status = receivingDetailIdo_dto.getStatus(); + //用户权限过期 + if ("401".equals(status)) { + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getRtosResponseData(bl, data, "401"); + } + if ("200".equals(status)) { + receivingDetailIdo = receivingDetailIdo_dto.getReceivingDetailIdo(); + } + //判断请求是否成功 + Boolean bl = "200".equals(status); + + //创建返回数据data + Map data = new HashMap<>(); + data.put("receivingDetailIdo", receivingDetailIdo); + //添加到返回对象 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 完成收车核对 + * + * @param vehicle_receiving_id:收车id + * @param ttiId:预约id + * @return 返回收车核对结果 + */ + @GetMapping("/vehicleReceivingOver") + public String vehicleReceivingOver(@RequestParam("vehicle_receiving_id") String vehicle_receiving_id, + @RequestParam("ttiId") String ttiId) { + String msg = null; + if (vehicle_receiving_id == null || vehicle_receiving_id.isEmpty()) { + msg = "收车凭证id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + if (ttiId == null || ttiId.isEmpty()) { + msg = "预约id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + //向哪吒提交完成收车核对请求 + //boolean res = vehicleService.vehicleReceivingOver(vehicle_receiving_id); + CommonRes res = orderApi.checkReceivingVehicle(vehicle_receiving_id); + //判断请求是否成功 + CheckRes myData = null; + //判断请求是否成功 + boolean bl = false; + if (res != null) { + myData = res.getData(); + bl = myData.isResult(); + msg = myData.getErrorMsg(); + } + + //如果核对成功,则修改预约/打卡状态 + if (bl) { + Appointment myAppointment = appointmentService.getAppointmentById(ttiId); + if (myAppointment == null) { + msg = "当前收车凭证id为 " + vehicle_receiving_id + ", 预约id为" + ttiId + ",但未找到对应的预约信息,无法进行完工打卡"; + //判断请求是否成功 + bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + + PunchClock myPunchClock = punchClockService.getPunchClockForAppintementId(ttiId); + if (myPunchClock != null && myPunchClock.getId() != null && !myPunchClock.getId().isEmpty()) { + PunchClock punchClock = punchClockService.postPunchClockOver(ttiId, myPunchClock.getId(), myPunchClock.getOver_address()); + } + } + + //创建返回数据对象 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + + /** + * 提车凭证分页列表数据(从Rtos请求数据) + * + * //@param users_id 当前页码 + * @return 分页数据 + */ + @GetMapping("/getVehicleDepartureInfoList") + public String getVehicleDepartureInfoList(@RequestParam("printTicketTime") String printTicketTime, + @RequestParam("query") String query, + @RequestParam("pageNum") Integer pageNum, + @RequestParam("pageSize") Integer pageSize) { + String msg = ""; + //解析分页参数 + pageNum = (pageNum != null && pageNum > 0) ? pageNum : 1; + pageSize = (pageSize != null && pageSize > 0) ? pageSize : 10; + System.out.print("当前页码:" + pageNum + ",数据条数:" + pageSize); + //通过RTOS接口读取提车凭证分页数据 + List myList = null; + //通过RTOS接口读取收车凭证分页数据 + DepartureVehicleIdo_DTO departureVehicleIdo_dto = vehicleService.getVehicleDepartureInfoList(printTicketTime, query, pageNum, pageSize); //当前页的列表数据 + String status = departureVehicleIdo_dto.getStatus(); + //用户权限过期 + if ("401".equals(status)) { + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getRtosResponseData(bl, data, "401"); + } + if ("200".equals(status)) { + myList = departureVehicleIdo_dto.getDepartureVehicleIdoList(); + } + //判断请求是否成功 + Boolean bl = "200".equals(status); + //创建返回数据对象 + Map data = new HashMap<>(); + data.put("pageNum", pageNum); + if (myList != null && myList.size() > 0) { + data.put("pageSize", myList.size()); + data.put("departureVehicleIdoList", myList); + } else { + data.put("pageSize", 0); + data.put("departureVehicleIdoList", null); + } + + //封装数据 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 提车凭证详细信息(从Rtos请求数据) + * + * @param vehicle_departure_id 提车凭证详id + * @return 返回提车凭证详细信息 + */ + @GetMapping("/getVehicleDepartureInfo") + public String getVehicleDepartureInfo(@RequestParam("vehicle_departure_id") String vehicle_departure_id) { + String msg = ""; + if (vehicle_departure_id == null || vehicle_departure_id.isEmpty()) { + msg = "提车凭证id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + DepartureDetailIdo departureDetailIdo = null; + //获取指定发车信息 + DepartureDetailIdo_DTO departureDetailIdo_dto = vehicleService.getVehicleDepartureInfo(vehicle_departure_id); + //判断请求是否成功 + String status = departureDetailIdo_dto.getStatus(); + //用户权限过期 + if ("401".equals(status)) { + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getRtosResponseData(bl, data, "401"); + } + if ("200".equals(status)) { + departureDetailIdo = departureDetailIdo_dto.getDepartureDetailIdo(); + } + //判断请求是否成功 + Boolean bl = "200".equals(status); + //创建返回数据data + Map data = new HashMap<>(); + data.put("departureDetailIdo", departureDetailIdo); + //添加到返回对象 + //返回 + return response.getResponseDataJavaJson(bl, data); + } + + /** + * 完成提车核对 + * + * @param vehicle_departure_id 提车凭证id + * @param ttiId:预约id + * @return 返回完成提车核对结果 + */ + @GetMapping("/VehicleDepartureOver") + public String VehicleDepartureOver(@RequestParam("vehicle_departure_id") String vehicle_departure_id, @RequestParam("ttiId") String ttiId) { + String msg = ""; + if (vehicle_departure_id == null || vehicle_departure_id.isEmpty()) { + msg = "提车凭证id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + if (ttiId == null || ttiId.isEmpty()) { + msg = "预约id不能为空"; + //判断请求是否成功 + Boolean bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + //向哪吒提交完成提车核对请求 + CommonRes res = orderApi.checkDepartureVehicle(vehicle_departure_id); + CheckRes myData = null; + //判断请求是否成功 + boolean bl = false; + if (res != null) { + myData = res.getData(); + bl = myData.isResult(); + msg = myData.getErrorMsg(); + } + + //如果核对成功,则修改预约/打卡状态 + if (bl) { + Appointment myAppointment = appointmentService.getAppointmentById(ttiId); + if (myAppointment == null) { + msg = "当前发车凭证id为 " + vehicle_departure_id + ", 预约id为" + ttiId + ",但未找到对应的预约信息,无法进行完工打卡"; + //判断请求是否成功 + bl = false; + //创建返回数据 + Map data = new HashMap<>(); + //封装数据 + return response.getResponseData(bl, data, msg); + } + PunchClock myPunchClock = punchClockService.getPunchClockForAppintementId(ttiId); + if (myPunchClock != null && myPunchClock.getId() != null && !myPunchClock.getId().isEmpty()) { + PunchClock punchClock = punchClockService.postPunchClockOver(ttiId, myPunchClock.getId(), myPunchClock.getOver_address()); + } + } + //创建返回数据对象 + Map data = new HashMap<>(); + //封装数据 + //返回 + return response.getResponseData(bl, data, msg); + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/config/ConfigHelper.java b/wx-applet/src/main/java/com/haitongauto/rtosac/config/ConfigHelper.java new file mode 100644 index 0000000..da7dfea --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/config/ConfigHelper.java @@ -0,0 +1,23 @@ +package com.haitongauto.rtosac.config; +import com.google.gson.Gson; +import net.sourceforge.tess4j.util.LoadLibs; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; + +public class ConfigHelper { + public static ForwardConfig getForwardConfig() { + ForwardConfig forwardConfig = null; + Gson gson = new Gson(); + File js = LoadLibs.extractTessResources("forward.json"); + try { + Reader reader = new FileReader(js); + // 将 JSON 文件内容解析为对象 + forwardConfig = gson.fromJson(reader, ForwardConfig.class); + + } catch (Exception ex) { + ex.printStackTrace(); + } + return forwardConfig; + } +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/config/ForwardConfig.java b/wx-applet/src/main/java/com/haitongauto/rtosac/config/ForwardConfig.java new file mode 100644 index 0000000..71cf2bc --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/config/ForwardConfig.java @@ -0,0 +1,11 @@ +package com.haitongauto.rtosac.config; + +import lombok.Data; + +@Data +public class ForwardConfig { + private String url; + + private Boolean isOpen; + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/Debounce.java b/wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/Debounce.java new file mode 100644 index 0000000..c94305f --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/Debounce.java @@ -0,0 +1,30 @@ +package com.haitongauto.rtosac.fangdou; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +public class Debounce { + private final DebounceInterface debounceInterface; + private final long delay; + private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();//对高并发有比较好的支持 + private ScheduledFuture future; + + public Debounce(DebounceInterface debounceInterface, long delay) { + this.debounceInterface = debounceInterface; + this.delay = delay; + } + + public void debounce() { + if (future != null && !future.isDone()) { + future.cancel(false); + } + + future = executor.schedule(() -> debounceInterface.execute(), delay, TimeUnit.MILLISECONDS); + } + + public void shutdown() { + executor.shutdown(); + } +} \ No newline at end of file diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/DebounceInterface.java b/wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/DebounceInterface.java new file mode 100644 index 0000000..1018ff7 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/DebounceInterface.java @@ -0,0 +1,5 @@ +package com.haitongauto.rtosac.fangdou; + +public interface DebounceInterface { + void execute(); +} \ No newline at end of file diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/AppointmentService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/AppointmentService.java new file mode 100644 index 0000000..c25791f --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/AppointmentService.java @@ -0,0 +1,145 @@ +package com.haitongauto.rtosac.service; + +import com.haitongauto.models.dto.AppointmentDto; +import com.haitongauto.models.forward.ForwardRes; +import com.haitongauto.models.pojo.*; +import com.haitongauto.models.valid.cus.ValidCusVin; +import com.haitongauto.models.valid.naz.CargoInfoNaz; + +import java.util.List; + +public interface AppointmentService { + ForwardRes invokeForwardApi(Appointment appointment, List appointmentDetailList); + + + void updateUserAndTruckByAppointment(Appointment appointment); + + /** + * 发起预约,根据用户Id获取用户板车注册信息 + * + * @param users_id 用户id + * @return 返回用户板车注册信息 + */ + Truck getPalletTruck(String users_id); + + /** + * 提交预约信息 + * + * @param appointment 预约数据实体 + * @return 返回提交结果 + */ + Integer postAppointment(Appointment appointment); + + /** + * 提交预约信息 + * + * @param appointment 预约数据实体 + * @return 返回提交结果 + */ + Integer postAppointmentDetailList(Appointment appointment, List appointmentDetailList); + + /** + * 查询指定用户是否存在已预约但未完成预约信息 + * + * @param users_id 司机id + * @return 返回查询结果 + */ + Appointment getActiveAppointment(String users_id); + + /** + * 查询指定板车是否存在已预约但未完成预约信息 + * @param truck_number 板车号 + * @return 返回查询结果 + */ + Appointment getActiveAppointmentNew(String truck_number); + + Appointment getActiveAppointmentByTruckNumber(String truck_number); + + /** + * 取消预约 + * + * @param appointment_id 预约id + * @return 返回执行取消预约的结果 + */ + Integer cancelAppointment(String appointment_id); + + /** + * 根据车牌号获取该用户的当前预约 + * + * @param truck_number 车牌号 + * @return 返回当前预约 + */ + Appointment getAppointmentByTruckNo(String truck_number); + + /** + * 根据车牌号获取该用户的当前预约(出闸口专用) + * + * @param truck_number 车牌号 + * @return 返回当前预约 + */ + Appointment getAppointmentByTruckNoForOutGate(String truck_number); + + + /** + * 通过更新一条预约信息,实现预约记录的进出港状态更新 + * + * @param appointment 预约数据实体 + * @return 返回更新执行结果 + */ + Integer updateAppointment(Appointment appointment); + + Integer updateAppointmentDetailList(Appointment appointment, List appointmentDetailList); + + /** + * 查询指定用户和指定车辆是否存在已预约但未完成预约信息 + * + * @param users_id 用户id + * @param truck_number 车牌号 + * @return 返回查询结果 + */ + Appointment getActiveAppointmentByUserAndTruck(String users_id, String truck_number); + + /** + * 根据id获得预约信息 + * + * @param id 预约id + * @return 返回预约信息 + */ + Appointment getAppointmentById(String id); + + List getAppointmentDetailListByAppointmentId(String appointment_id); + + AppointmentDto getAppointmentDtoById(String id); + + + /** + * 查询用户当天在外高桥港区未离港的预约 + * + * @param users_id 用户id + * @param port_area_id 港区id + * @param approach_date 进港日期 + * @return 返回预约信息 + */ + Appointment getAppointmentByUserIdAndPortAreaIdAndApproachDate(String users_id, String port_area_id, String approach_date); + + Integer updateAppointmentPlateScanTime(String appointment_id); + + List getAppointmentDetailListByGoodVinList(List vinlist); + + //根据 Vin列表查询匹配的商品车明细,并筛选出不属于已取消和异常的预约的 + List getAppointmentDetailListByVinList(List vinlist, String appointmentId); + + Integer deleteAppointmentDetailByAppointmentId(String appointment_id); + + /** + * 激活验证,返回商品企业信息 + * + * @param vinList vin + * @return 激活验证,返回商品企业信息 + */ + List validCusVin(List vinList); + + List cargoInfoNaz(List validCusVinList,String truckNum); + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/ForwardService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/ForwardService.java new file mode 100644 index 0000000..eb999ad --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/ForwardService.java @@ -0,0 +1,31 @@ +package com.haitongauto.rtosac.service; + +import com.haitongauto.models.forward.AppointOverState; +import com.haitongauto.models.forward.ForwardRes; +import com.haitongauto.models.forward.UserTruck; +import com.haitongauto.models.pojo.Appointment; +import com.haitongauto.models.pojo.AppointmentDetail; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public interface ForwardService { + /*** + * 预约信息异步转发到老系统 + * @param + * @return 返回进港 + */ + public CompletableFuture invokeApiAsyncForward(Appointment appointment, List appointmentDetailList); + + + /*** + * 预约信息完成,将完成状态同步到老系统(整车物流) + * @param + * @return 返回进港 + */ + public CompletableFuture appointmentOverApiAsync(AppointOverState appointOverState); + + + Integer execUserTruck(List userTrucks); + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/HomeService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/HomeService.java new file mode 100644 index 0000000..703a68a --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/HomeService.java @@ -0,0 +1,142 @@ +package com.haitongauto.rtosac.service; + +import com.github.pagehelper.PageInfo; +import com.haitongauto.models.dto.DataForMessage; +import com.haitongauto.models.ido.login.PostLoginRes; +import com.haitongauto.models.pojo.Users; +import com.haitongauto.models.pojo.Truck; +import com.haitongauto.models.pojo.Announcement; +import com.haitongauto.models.sysuser.OldSysTruck; +import com.haitongauto.models.sysuser.OldSysUser; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.util.Map; + +public interface HomeService { + + void userInfoSync1(OldSysUser applet_users, OldSysTruck applet_truck); + + + Users userInfoSync(String wx_openid, String tel_number); + + Users getUsersForId(String id); + + /** + * 根据用户的小程序 openid 获取用户在数据库里的数据 + * + * @param wx_openid 微信openid + * @return 返回用户信息 + */ + Users getUsersForOpenId(String wx_openid); + + String insertTruck(Truck truck); + + Integer updateTruck(Truck truck); + + /** + * 用户/车辆注册 + * + * @param users 用户 + * @return 返回执行结果 + */ + PostLoginRes postLogin(Users users); + + /** + * 写入登录日志 + * + * @param wx_openid wx_openid + * @param ip ip地址 + */ + void loginLogAdd(String wx_openid, String ip); + + /** + * 分页读取每页10条公告数据 + * + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回分页数据 + */ + PageInfo getAnnouncementsList(Integer pageNum, Integer pageSize, Integer sort, String keyWords); + + /** + * 根据公告id获得公告 + * + * @param announcement_id 公告id + * @return 返回公告信息 + */ + Announcement getAnnouncementById(String announcement_id); + + /** + * 读取系统服务路径 + * + * @return 返回系统服务路径 + */ + String getServiceBaseUrl(); + + /** + * 读取图片访问路径 + * + * @return 返回图片路径 + */ + String getImgAccessUrl(); + + /** + * 根据配置编号获取配置值 + * + * @param config_code 配置编号 + * @return 返回配置值 + */ + String getServiceConfigForCode(String config_code); + + /** + * 获取外部接口数据 + * + * @param request_type : 请求类型参数,取值于Requester表 + * @param myParamMap :实时传值,其键值对与 Requester表param字段的键值对对应 + * @return 返回外部接口数据 + */ + String getExternalInterfaceData(Integer request_type, Map myParamMap); + + /** + * 发送订阅消息 + * + * @param dataForMessage:订阅消息发送数据类的实例 + * @return 发送失败的错误信息 + */ + String sendMessage(DataForMessage dataForMessage); + + /** + * 返回文件后缀 + * + * @param file 文件 + * @return 返回文件后缀 + */ + String getImagePath(MultipartFile file); + + /** + * 保存图片 + * + * @param mfile 文件 + * @param file 文件 + * @return 返回执行结果 + */ + boolean saveImage(MultipartFile mfile, File file); + + /** + * 新文件名 + * + * @param suffix suffix + * @return 返回文件名 + */ + String getNewFileName(String suffix); + + /** + * 返回图片保存地址 + * + * @param name 文件名 + * @return 返回图片保存地址 + */ + String getNewImagePath(String name); + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/MessageService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/MessageService.java new file mode 100644 index 0000000..fec3925 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/MessageService.java @@ -0,0 +1,50 @@ +package com.haitongauto.rtosac.service; + +import com.github.pagehelper.PageInfo; +import com.haitongauto.models.pojo.Appointment; +import com.haitongauto.models.pojo.Message; + +public interface MessageService { + + String insert(Message message); + + int update(Message message); + + /** + * 哪吒打印的时候向小程序发送消息(哪吒请求接口) + * + * @param message 消息实体 + * @return 返回结果 + */ + boolean receiveMessage(Message message); + + /** + * 根据板车号获得该板车最新消息 + * @param type 收车/发车 + * @return 返回消息 + */ + Message getLastMessageByTypeAndBizId(Integer type, String biz_id); + + PageInfo getUnReadMessageListByWxOpenid(String wxOpenid, Integer pageNum, Integer pageSize); + + /** + * 微信小程序前端打开界面,获得所有消息列表 + * + * @param wxOpenid 微信openId + * @return 返回结果 + */ + PageInfo getMessageListByWxOpenid(String wxOpenid, Integer pageNum, Integer pageSize); + + /** + * 微信小程序前端打开界面,获得所有未读消息数量 + * + * @param wxOpenid 微信openId + * @return 返回结果 + */ + Integer sumUnread(String wxOpenid); + + + Appointment punchClockOverByPrint(String appointmentId); + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/MineService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/MineService.java new file mode 100644 index 0000000..eb4eb89 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/MineService.java @@ -0,0 +1,137 @@ +package com.haitongauto.rtosac.service; + +import com.github.pagehelper.PageInfo; +import com.haitongauto.models.pojo.*; + +import java.util.List; + +public interface MineService { + + /** + * 个人资料修改 + * + * @param users 用户(司机) + * @return 返回修改结果 + */ + Integer postMyUsers(Users users); + + + /** + * 获取我的板车信息 + * + * @param truckId 板车id + * @return 返回我的板车信息 + */ + Truck getTruck(String truckId); + + /** + * 获取我的板车信息 + * + * @param users_id 司机id + * @return 返回我的板车信息 + */ + List getMyPalletTruck(String users_id); + + /** + * 修改或添加我的板车信息 + * + * @param palletTruck 板车数据实体 + * @return 返回执行结果 + */ + Integer postMyPalletTruck(Truck palletTruck); + + /** + * 删除我的板车信息 + * + * @param palletTruck_id 板车id + * @return 返回执行结果 + */ + Integer delMyPalletTruck(String palletTruck_id); + + Integer deleteTruckByUsersId(String users_id); + + /** + * 我的车辆黑名单信息 truck_management + * + * @param users_id 司机id + * @return 返回我的车辆黑名单信息 + */ + List getMyTruckManagement(String users_id); + + /** + * 提交反馈意见 + * + * @param feedback 反馈意见数据实体 + * @return 返回执行结果 + */ + Integer postFeedback(Feedback feedback); + + /** + * 我的预约信息列表 + * + * @param users_id 司机id + * @return 返回我的预约信息列表 + */ + List getMyAppointmentList(String users_id); + + + /** + * 根据预约ids + * + * @param ids 预约ids + * @return 返回预约列表 + */ + + public List getAppointmentByIds(List ids); + + + /** + * 我的预约信息模糊查询分页列表 + * + * @param users_id 司机id + * @param keywords 查询关键字 + * @param approach_date 进场日期 + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回我的预约信息模糊查询分页列表 + */ + PageInfo getMyAppointmentListForPage(String users_id, String keywords, String approach_date, Integer pageNum, Integer pageSize); + + PageInfo getMyAppointmentListForPageNew(String users_id, String keywords, String approach_date, Integer pageNum, Integer pageSize); + + /** + * 我的预约信息按日期查询分页列表 + * + * @param users_id 司机id + * @param approach_date 预约进场日期 + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回我的预约信息按日期查询分页列表 + */ + PageInfo getMyAppointmentListByDateForPage(String users_id, String approach_date, Integer pageNum, Integer pageSize); + + /** + * 新手攻略 + * + * @return 返回新手攻略 + */ + List getNoviceIntroduction(); + + /** + * 获取我的当前预约 + * + * @param users_id 用户id + * @return 返回获取我的当前预约 + */ + Appointment getMyAppointment(String users_id); + + /** + * 根据Id获取用户信息 + * + * @param users_id 用户id + * @return 返回用户信息 + */ + Users getUsersById(String users_id); + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/NewsService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/NewsService.java new file mode 100644 index 0000000..7d47415 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/NewsService.java @@ -0,0 +1,17 @@ +package com.haitongauto.rtosac.service; +import com.haitongauto.models.pojo.EntryInstruct; +import com.haitongauto.models.pojo.Requester; +import java.util.List; + +public interface NewsService { + + /** + * 获取发送给指定用户的(最近10条)指令信息 + * @param users_id 用户id + * @return 返回定用户的(最近10条)指令信息 + */ + List getEntryInstructionsForUsers(String users_id); + + Requester getRequesterForType(Integer requestType); + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/PunchClockService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/PunchClockService.java new file mode 100644 index 0000000..4ec818f --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/PunchClockService.java @@ -0,0 +1,110 @@ +package com.haitongauto.rtosac.service; + +import com.haitongauto.models.pojo.Appointment; +import com.haitongauto.models.pojo.PortArea; +import com.haitongauto.models.pojo.PunchClock; + +import javax.xml.crypto.Data; +import java.util.Date; +import java.util.List; + +public interface PunchClockService { + /** + * 检查是否有预约(查询是否存在有预约待签到)的预约数据 + * + * @param users_id 用户id + * @return 返回预约信息 + */ + Appointment getIincompleteAppointment(String users_id); + + /** + * 签到打卡提交 + * + * @param users_id 用户id + * @param appointment_id 预约id + * @param port_area_id 港区id + * @param punch_poi 坐标 + * @return 返回提交结果 + */ + PunchClock postPunchClockStart(String users_id, String appointment_id, String port_area_id, String punch_poi, String punch_address); + + /** + * 完成打卡提交 + * + * @param appointment_id 预约id + * @param punch_clock_id 打卡id + * @param over_address 打卡地址 + * @return 返回完成打卡提交执行结果 + */ + PunchClock postPunchClockOver(String appointment_id, String punch_clock_id, String over_address); + + /** + * 根据预约Id获取获取打卡记录 + * + * @param appointment_id 预约id + * @return 返回打卡记录 + */ + PunchClock getPunchClockForAppintementId(String appointment_id); + + /** + * 查询指定司机某一天(指定日期)的打卡记录 + * + * @param date 指定日期 + * @param users_id 用户id + * @return 返回打卡记录列表 + */ + List getPunchClockForDate(String date, String users_id); + + /** + * 查询指定司机某年某月的打卡记录 + * + * @param year 年 + * @param month 月 + * @param users_id 用户id + * @return 返回打卡记录列表 + */ + List getPunchClockForYM(Integer year, Integer month, String users_id); + + /** + * 获取港区 + * + * @param port_area_id 港区id + * @return 返回港区信息 + */ + PortArea getPortAreaForId(String port_area_id); + + /** + * 获取港区中心点坐标 + * + * @param port_area_id 港区id + * @return 返回港区中心点坐标 + */ + String getPortAreaPoi(String port_area_id); + + /** + * 获取签到打卡排队序号 + * + * @param appointment_id 预约id + * @return 返回签到打卡排队序号 + */ + String getQueueNumber(String appointment_id); + + /** + * 获取当前排队前面还剩多少车辆未进港 + * + * @param approach_date 进场日期 + * @param port_area_id 港区id + * @param queue_number 排队号 + * @return 返回查询结果 + */ + Integer getNumberBefore(String approach_date, String port_area_id, String queue_number); + + Integer updatePunchClock(PunchClock punchClock); + + + String getLastQueueNumber(Date date, String port_area_id); + + + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/Response.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/Response.java new file mode 100644 index 0000000..5c271d8 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/Response.java @@ -0,0 +1,42 @@ +package com.haitongauto.rtosac.service; + +public interface Response { + /** + * 封装为返回Json对象 + * + * @param bl:请求是否成功 + * @param data:返回数据 + * @return 返回Json对象 + */ + String getResponseData(Boolean bl, Object data); + + /** + * 封装为返回Json对象 + * + * @param bl 请求是否成功 + * @param data 返回数据 + * @param msg 消息 + * @return 返回Json对象 + */ + String getResponseData(Boolean bl, Object data, String msg); + + /** + * 封装为返回Json对象(带null) + * @param bl:请求是否成功 + * @param data:返回数据 + * @return 返回Json对象 + */ + String getResponseDataJavaJson(Boolean bl,Object data); + + + /** + * 封装为返回Json对象(带null) + * @param bl:请求是否成功 + * @param data:返回数据 + * @return 返回Json对象 + */ + String getRtosResponseData(Boolean bl,Object data,String errorCode); + + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/UsersService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/UsersService.java new file mode 100644 index 0000000..e1e1ec7 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/UsersService.java @@ -0,0 +1,15 @@ +package com.haitongauto.rtosac.service; +import com.haitongauto.models.pojo.Truck; +import com.haitongauto.models.pojo.Users; + +public interface UsersService { + String insert(Users users); + + Integer update(Users users); + + Truck getTruckByWxOpenID(String wx_openid); + + Truck getTruckByUserId(String userId); + + Users getUsersByUserId(String userId); +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/VehicleService.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/VehicleService.java new file mode 100644 index 0000000..b1ab4ad --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/VehicleService.java @@ -0,0 +1,59 @@ +package com.haitongauto.rtosac.service; +import com.haitongauto.models.ido.departure.DepartureDetailIdo_DTO; +import com.haitongauto.models.ido.departure.DepartureVehicleIdo_DTO; +import com.haitongauto.models.ido.receiving.ReceivingDetailIdo_DTO; +import com.haitongauto.models.ido.receiving.ReceivingVehicleIdo_DTO; +public interface VehicleService { + /** + * 获取收车凭证的分页数据 + * + * @param current 当前页码 + * @param size 数据条数(非必填) + * @return 返回收车凭证的分页数据 + */ + ReceivingVehicleIdo_DTO getVehicleReceivingList(String printTicketTime, String query, Integer current, Integer size); + //ReceivingVehicleIdo_DTO getVehicleReceivingList(String access_token, Integer current, Integer size); + + /** + * 获取指定id的待核对收车凭证信息 + * access_token 访问令牌(根据该用户access_token权限获得该用户的收车凭证)用户登录后前端会保存access_token + * + * @param id 收车凭证id + * @return 返回收车凭证信息 + */ + ReceivingDetailIdo_DTO getVehicleReceivingInfo(String id); + + /** + * 完成收车核对 + * + * @param id 收车凭证id + * @return 返回核对结果 + */ + boolean vehicleReceivingOver(String id); + + /** + * 获取提车凭证的分页数据 + * + * @param current 当前页码 + * @param size 数据条数(非必填) + * @return 返回提车凭证的分页数据 + */ + DepartureVehicleIdo_DTO getVehicleDepartureInfoList(String printTicketTime, String query, Integer current, Integer size); + + /** + * 获取指定id的待核对提车信息 + * + * @param id 待提车id + * @return 返回指定id的待核对提车信息 + */ + DepartureDetailIdo_DTO getVehicleDepartureInfo(String id); + + /** + * 完成发车核对 + * + * @param id 提车凭证id + * @return 返回提车凭证id的提车信息 + */ + boolean VehicleDepartureOver(String id); + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/AppointmentServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/AppointmentServiceImpl.java new file mode 100644 index 0000000..7f09a1d --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/AppointmentServiceImpl.java @@ -0,0 +1,816 @@ +package com.haitongauto.rtosac.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.bestvike.linq.Linq; +import com.haitongauto.interfaces.*; +import com.haitongauto.mapper.base.*; +import com.haitongauto.mapper.client.PunchClockExtendMapper; +import com.haitongauto.mapper.client.TruckExtendMapper; +import com.haitongauto.models.dto.AppointmentDto; +import com.haitongauto.models.dto.DicDto; +import com.haitongauto.models.dto.EnterPortTypeDtol; +import com.haitongauto.models.forward.AppointForward; +import com.haitongauto.models.forward.ForwardRes; +import com.haitongauto.models.forward.VinDetail; +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.CargoInfo; +import com.haitongauto.models.valid.naz.CargoInfoNaz; +import com.haitongauto.models.valid.naz.EnterpriseInfo; +import com.haitongauto.models.valid.naz.Good; +import com.haitongauto.rtosac.api.AppointmentController; +import com.haitongauto.rtosac.service.AppointmentService; +import com.haitongauto.mapper.client.AppointmentExtendMapper; +import com.haitongauto.rtosac.service.MessageService; +import com.haitongauto.utils.FormatDateTime; +import com.haitongauto.utils.HttpClientHelper; +import com.haitongauto.utils.QueueNumberHelper; +import com.haitongauto.utils.http.OkHttpUtils; +import lombok.extern.slf4j.Slf4j; +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.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; + +@Slf4j +@Service +public class AppointmentServiceImpl implements AppointmentService { + /** + * 读取nacos接口路径(正常物流,预约信息同步老系统的接口地址) + */ + @Value("${rtos.syncold.url}") + private String myUrl; + + @Autowired + PunchClockExtendMapper punchClockExtendMapper; + @Autowired + PunchClockMapper punchClockMapper; + @Autowired + TruckMapper truckMapper; + @Autowired + PortAreasMapper portAreasMapper; + @Autowired + AppointmentMapper appointmentMapper; + @Autowired + AppointmentDetailMapper appointmentDetailMapper; + @Autowired + AppointmentExtendMapper appointmentExtendMapper; + @Autowired + TruckExtendMapper truckExtendMapper; + @Autowired + PortAreaInterface portAreaInterface; + @Autowired + DicInterface dicInterface; + @Autowired + EnterPortTypeInterface enterPortTypeInterface; + @Autowired + UsersMapper usersMapper; + + @Resource + CusOrderApi cusOrderApi; + + @Resource + OrderApi orderApi; + + + private static final Logger logger = LogManager.getLogger(AppointmentServiceImpl.class); + + @Override + public ForwardRes invokeForwardApi(Appointment appointment, List appointmentDetailList) { + if (appointment == null) { + return null; + } + AppointForward appointForward = new AppointForward(); + //appointForward.setId(appointment.getId());//预约id + appointForward.setTruckNo(appointment.getTruck_number());//板车号 + appointForward.setPhone(appointment.getTel_number());//手机号码 + appointForward.setGodNum(appointment.getGoods_quantity());//货物数量 + appointForward.setOrderTm(appointment.getApproach_date());//预约时间 + Users users = usersMapper.getById(appointment.getUsers_id()); + if (users != null) { + appointForward.setOpenId(users.getWx_openid());//openid + } + PortArea portArea = portAreasMapper.getById(appointment.getPort_area_id()); + if (portArea != null) { + appointForward.setWhafType(portArea.getPort_area_name());//港区 + } + String goods_type = appointment.getGoods_type(); + //货物类型 + if (goods_type != null && !goods_type.isEmpty()) { + switch (goods_type) { + case "C": { + appointForward.setGodType("商品车"); + break; + } + case "L": { + appointForward.setGodType("大件"); + break; + } + case "M": { + appointForward.setGodType("工程机械"); + break; + } + } + } + + //进港类型 + String enter_type = appointment.getEnter_type(); + if (enter_type != null && !enter_type.isEmpty()) { + switch (enter_type) { + case "WE": { + appointForward.setOrderType("外贸出口"); + break; + } + case "WI": { + appointForward.setOrderType("外贸进口"); + break; + } + case "NE": { + appointForward.setOrderType("内贸出口"); + break; + } + case "NI": { + appointForward.setOrderType("内贸进口"); + break; + } + case "BC": { + appointForward.setOrderType("奔驰分拨"); + break; + } + case "LP": { + appointForward.setOrderType("提离港区"); + break; + } + case "BM": { + appointForward.setOrderType("宝马分拨"); + break; + } + case "JL": { + appointForward.setOrderType("捷豹路虎分拨"); + break; + } + case "AC": { + appointForward.setOrderType("安盛场地"); + break; + } + case "FT": { + appointForward.setOrderType("丰田分拨"); + break; + } + case "AD": { + appointForward.setOrderType("奥迪分拨"); + break; + } + case "OTHER": { + appointForward.setOrderType("其他品牌分拨"); + break; + } + case "MV": { + appointForward.setOrderType("移库短驳"); + break; + } + case "PD": { + appointForward.setOrderType("整车分拨"); + break; + } + } + } + + List vinDetails = null; + if (appointmentDetailList != null && appointmentDetailList.size() > 0) { + vinDetails = new ArrayList<>(); + for (AppointmentDetail appointmentDetail : appointmentDetailList) { + VinDetail vinDetail = new VinDetail(); + vinDetail.setVin(appointmentDetail.getVin());//车架号 + String shipName = appointmentDetail.getShip_name(); + if (shipName != null && !shipName.isEmpty()) { + String myShipName = shipName.split("/")[0]; + vinDetail.setVlsNm(myShipName);//船名 + } + String brandName = appointmentDetail.getBrand_name(); + if (brandName != null && !brandName.isEmpty()) { + String myBrandName = brandName.split("/")[0]; + vinDetail.setBrdNm(myBrandName);//品牌 + } + String destinationPort = appointmentDetail.getDestination_port(); + if (destinationPort != null && !destinationPort.isEmpty()) { + String myDestinationPort = destinationPort.split("/")[0]; + vinDetail.setPotNm(myDestinationPort);//港口 + } + vinDetails.add(vinDetail); + } + } + appointForward.setDataList(vinDetails); + + //调用哪吒接口,将预约数据转发到,老系统,待补充 + //String myUrl = "http://192.168.161.81:8090/rtopswebapi/api/NsOrder/execTruckOrder"; + ForwardRes forwardRes = null; + //ForwardConfig config= ConfigHelper.getForwardConfig(); + //if (config != null) { + // myUrl = config.getUrl() + "execTruckOrder"; + //} + try { + logger.info("预约信息转发:" + JSON.toJSONString(appointForward)); + String post = OkHttpUtils.post(myUrl, OkHttpUtils.buildJsonRequestBody(JSON.toJSONString(appointForward)), null); + JSONObject rst = JSONObject.parseObject(post); + logger.info("预约信息转发回复:" + JSONObject.toJSONString(rst)); + + //解析成实体 + if (post != null && post.contains("success")) { + forwardRes = JSONObject.parseObject(post, ForwardRes.class); + } + } catch (Exception e) { + logger.info("预约信息转发回复:" + JSON.toJSONString(e.getMessage())); + } + return forwardRes; + } + + @Override + public void updateUserAndTruckByAppointment(Appointment appointment) { + if (appointment == null) { + return; + } + String users_id = appointment.getUsers_id(); + if (users_id == null || users_id.isEmpty()) { + return; + } + Users myUsers = usersMapper.getById(users_id); + if (myUsers != null) { + myUsers.setTel_number(appointment.getTel_number()); + myUsers.setId_code(appointment.getId_code()); + usersMapper.update(myUsers); + } + + Truck myTruck = truckMapper.getTruckByUsersId(users_id); + if (myTruck != null) { + myTruck.setUsers_id(users_id); + myTruck.setTel_number(appointment.getTel_number()); + myTruck.setTruck_number(appointment.getTruck_number()); + myTruck.setVehicle_frame_weight(appointment.getVehicle_frame_weight()); + myTruck.setVehicle_weight(appointment.getVehicle_weight()); + myTruck.setHead_frame_number(appointment.getTruck_vin()); + myTruck.setDriving_license(appointment.getDriving_license()); + if (myUsers != null) { + myTruck.setWx_openid(myUsers.getWx_openid()); + } + truckMapper.update(myTruck); + } else { + myTruck = new Truck(); + myTruck.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase()); + myTruck.setUsers_id(users_id); + myTruck.setTel_number(appointment.getTel_number()); + myTruck.setTruck_number(appointment.getTruck_number()); + myTruck.setVehicle_frame_weight(appointment.getVehicle_frame_weight()); + myTruck.setVehicle_weight(appointment.getVehicle_weight()); + myTruck.setHead_frame_number(appointment.getTruck_vin()); + myTruck.setDriving_license(appointment.getDriving_license()); + if (myUsers != null) { + myTruck.setWx_openid(myUsers.getWx_openid()); + } + truckMapper.insert(myTruck); + } + } + + /** + * (发起预约时)获取用户注册的板车信息 + * + * @param users_id 司机id + * @return 返回用户注册的板车信息 + */ + @Override + public Truck getPalletTruck(String users_id) { + //获取该用户的板车信息 + return truckMapper.getTruckByUsersId(users_id); + } + + /** + * 提交预约信息 + * + * @param appointment 预约数据实体 + * @return 返回提交结果 + */ + @Override + public Integer postAppointment(Appointment appointment) { + Integer res = 0; + String id = appointment.getId(); + if (id == null || id.isEmpty()) { + //插入 + String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase(); + appointment.setId(uuid); + //数据补全 + String myDate = FormatDateTime.dateTimeToStr(new Date()); + appointment.setAppointment_state(1); + appointment.setCreate_time(myDate); + appointment.setUpdate_time(myDate); + appointment.setIs_del(0); + //写入 + String myId = appointmentMapper.insert(appointment); + res = (myId != null && myId.length() > 0) ? 1 : null; + //插入打卡记录 + if (res != null) { + PunchClock punchClock = new PunchClock(); + punchClock.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase()); + punchClock.setPunch_clock_type(0); + punchClock.setPort_area_id(appointment.getPort_area_id()); + punchClock.setAppointment_id(appointment.getId()); + punchClock.setBiz_type(appointment.getBiz_type()); + punchClock.setUsers_id(appointment.getUsers_id()); + punchClock.setCreate_time(myDate); + punchClock.setUpdate_time(myDate); + punchClock.setIs_del(0); + String punchClockId = punchClockMapper.insert(punchClock); + } + + } else { + //修改 + res = appointmentMapper.update(appointment); + if (res != null) { + PunchClock myPunchClock = punchClockMapper.getPunchClockByAppointmentId(appointment.getId()); + if (myPunchClock != null) { + myPunchClock.setPort_area_id(appointment.getPort_area_id()); + myPunchClock.setAppointment_id(appointment.getId()); + myPunchClock.setBiz_type(appointment.getBiz_type()); + myPunchClock.setUsers_id(appointment.getUsers_id()); + myPunchClock.setIs_del(0); + Integer x = punchClockMapper.update(myPunchClock); + } + } + + } + //返回 + return res; + } + + /** + * 预约明细提交 + * + * @param appointment 预约数据实体 + * @param appointmentDetailList 明细列表 + * @return 返回执行影响条数 + */ + @Override + public Integer postAppointmentDetailList(Appointment appointment, List appointmentDetailList) { + int res = 0; + if (appointment == null || appointmentDetailList == null || appointmentDetailList.size() == 0) { + return res; + } + List myAppointmentDetailList = appointmentDetailMapper.getAppointmentDetailListByAppointmentId(appointment.getId()); + for (AppointmentDetail appointmentDetail : appointmentDetailList) { + AppointmentDetail myAppointmentDetail = null; + if (myAppointmentDetailList != null && myAppointmentDetailList.size() > 0) { + myAppointmentDetail = Linq.of(myAppointmentDetailList).firstOrDefault(p -> p.getVin().equals(appointmentDetail.getVin())); + } + //新增 + if (myAppointmentDetail == null) { + appointmentDetail.setAppointment_id(appointment.getId()); + appointmentDetail.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase()); + appointmentDetail.setIs_del(0); + String r = appointmentDetailMapper.insert(appointmentDetail); + if (r != null && !r.isEmpty()) { + res = res + 1; + } + } else { + //修改 + appointmentDetail.setIs_del(0); + int x = appointmentDetailMapper.update(appointmentDetail); + res = res + x; + } + } + return res; + } + + /** + * 查询指定用户是否存在已预约但未完成预约信息 + * + * @param users_id 司机id + * @return 返回查询结果 + */ + @Override + public Appointment getActiveAppointment(String users_id) { + return appointmentExtendMapper.getActiveAppointment(users_id); + } + + @Override + public Appointment getActiveAppointmentNew(String truck_number) { + return appointmentExtendMapper.getActiveAppointmentNew(truck_number); + } + + @Override + public Appointment getActiveAppointmentByTruckNumber(String truck_number) { + return appointmentExtendMapper.getActiveAppointmentByTruckNumber(truck_number); + } + + /** + * 取消预约 + * + * @param appointment_id 预约id + * @return 返回执行取消预约的结果 + */ + @Override + public Integer cancelAppointment(String appointment_id) { + String cancel_time = FormatDateTime.dateTimeToStr(new Date()); + int x = 0; + //取消预约 + x = appointmentExtendMapper.cancelAppointment(cancel_time, appointment_id); + //取消对应的预约明细 + //int count = appointmentExtendMapper.cancelAppointmentDetails(appointment_id); + + return x; + } + + /** + * 根据车牌号获取该用户的当前预约 + * + * @param truck_number 车牌号 + * @return 返回当前预约 + */ + @Override + public Appointment getAppointmentByTruckNo(String truck_number) { + Appointment appointment = null; + List appointmentList = appointmentMapper.getListByTruckName(truck_number); + if (appointmentList != null && appointmentList.size() > 0) { + appointment = Linq.of(appointmentList).firstOrDefault(); + } + return appointment; + } + + /** + * 根据车牌号获取该用户的当前预约(出闸口专用) + * + * @param truck_number 车牌号 + * @return 返回当前预约 + */ + @Override + public Appointment getAppointmentByTruckNoForOutGate(String truck_number) { + return appointmentMapper.getAppointmentByTruckNoForOutGate(truck_number); + } + + /** + * 通过更新一条预约信息,实现预约记录的进出港状态更新 + * + * @param appointment 预约数据实体 + * @return 返回更新执行结果 + */ + @Override + public Integer updateAppointment(Appointment appointment) { + return appointmentMapper.update(appointment); + } + + /** + * 预约明细提交 + * + * @param appointment 预约数据实体 + * @param appointmentDetailList 明细列表 + * @return 返回执行影响条数 + */ + @Override + public Integer updateAppointmentDetailList(Appointment appointment, List appointmentDetailList) { + int res = 0; + if (appointment == null || appointmentDetailList == null || appointmentDetailList.size() == 0) { + return res; + } + String appointmentId = appointment.getId(); + if (appointmentId == null || appointmentId.isEmpty()) { + return res; + } + //删除修改前的预约明细 + int result = appointmentDetailMapper.deleteAppointmentDetailByAppointmentId(appointmentId); + for (AppointmentDetail appointmentDetail : appointmentDetailList) { + //新增 + if (appointmentDetail != null) { + appointmentDetail.setAppointment_id(appointment.getId()); + String id_Detail = appointmentDetail.getId(); + if (id_Detail == null || id_Detail.isEmpty()) { + //前端可能新增了一条车vin, + appointmentDetail.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase()); + } + appointmentDetail.setIs_del(0); + String r = appointmentDetailMapper.insert(appointmentDetail); + if (r != null && !r.isEmpty()) { + res = res + 1; + } + } + + } + return res; + } + + /** + * 查询指定用户和指定车辆是否存在已预约但未完成预约信息 + * + * @param users_id 用户id + * @param truck_number 车牌号 + * @return 返回查询结果 + */ + @Override + public Appointment getActiveAppointmentByUserAndTruck(String users_id, String truck_number) { + return appointmentExtendMapper.getActiveAppointmentByUserAndTruck(users_id, truck_number); + } + + /** + * 根据id获得预约信息 + * + * @param id 预约id + * @return 返回预约信息 + */ + @Override + public Appointment getAppointmentById(String id) { + return appointmentMapper.getById(id); + } + + @Override + public List getAppointmentDetailListByAppointmentId(String appointment_id) { + return appointmentDetailMapper.getAppointmentDetailListByAppointmentId(appointment_id); + } + + @Override + public AppointmentDto getAppointmentDtoById(String id) { + Appointment appointment = appointmentMapper.getById(id); + if (appointment == null) { + return null; + } + AppointmentDto appointmentDto = new AppointmentDto(); + //港区 + String port_area_id = appointment.getPort_area_id(); + List portAreaList = portAreaInterface.getPortArea(); + PortArea portArea = null; + if (portAreaList != null) { + portArea = Linq.of(portAreaList).firstOrDefault(p -> p.getId().equals(port_area_id)); + } + //运输方式 + String transport_type = appointment.getTransport_type(); + List transportTypelist = dicInterface.getDicList("TRANSPORT_TYPE"); + DicDto transportType = null; + if (transportTypelist != null) { + transportType = Linq.of(transportTypelist).firstOrDefault(p -> p.getId().equals(transport_type)); + } + //进港类型 + String enter_type = appointment.getEnter_type(); + List enterTypelist = enterPortTypeInterface.getEnterPortTypeList(); + EnterPortTypeDtol enterType = null; + if (enterTypelist != null) { + enterType = Linq.of(enterTypelist).firstOrDefault(p -> p.getId().equals(enter_type)); + } + //货物类型 + String goods_type = appointment.getGoods_type(); + List goodsTypelist = dicInterface.getDicList("APP_CARGO_TYPE"); + DicDto goodsType = null; + if (goodsTypelist != null) { + goodsType = Linq.of(goodsTypelist).firstOrDefault(p -> p.getId().equals(goods_type)); + } + + appointmentDto.setId(appointment.getId()); + appointmentDto.setBiz_type(appointment.getBiz_type()); + appointmentDto.setUsers_id(appointment.getUsers_id()); + appointmentDto.setTruck_number(appointment.getTruck_number()); + appointmentDto.setId_code(appointment.getId_code()); + appointmentDto.setTel_number(appointment.getTel_number()); + appointmentDto.setTruck_vin(appointment.getTruck_vin()); + appointmentDto.setVehicle_weight(appointment.getVehicle_weight()); + appointmentDto.setVehicle_frame_weight(appointment.getVehicle_frame_weight()); + appointmentDto.setDriving_license(appointment.getDriving_license()); + appointmentDto.setApproach_date(appointment.getApproach_date()); + appointmentDto.setGoods_quantity(appointment.getGoods_quantity()); + appointmentDto.setAppointment_state(appointment.getAppointment_state()); + appointmentDto.setCancel_time(appointment.getCancel_time()); + appointmentDto.setCreate_time(appointment.getCreate_time()); + appointmentDto.setUpdate_time(appointment.getUpdate_time()); + appointmentDto.setIs_del(appointment.getIs_del()); + appointmentDto.setPort_area_id(appointment.getPort_area_id()); + appointmentDto.setAppointment_type(appointment.getAppointment_type()); + if (appointmentDto.getAppointment_state().equals(1)) { + appointmentDto.setAppointment_type_name("普通码头预约"); + } + if (appointmentDto.getAppointment_state().equals(2)) { + appointmentDto.setAppointment_type_name("特保区预约"); + } + if (portArea != null) { + appointmentDto.setPort_area_name(portArea.getPort_area_name()); + } + appointmentDto.setEnter_type(appointment.getEnter_type()); + if (enterType != null) { + appointmentDto.setEnter_type_name(enterType.getText()); + } + appointmentDto.setGoods_type(appointment.getGoods_type()); + if (goodsType != null) { + appointmentDto.setGoods_type_name(goodsType.getText()); + } + appointmentDto.setTransport_type(appointment.getTransport_type()); + if (transportType != null) { + appointmentDto.setTransport_type_name(transportType.getText()); + } + + return appointmentDto; + } + + + /** + * 查询用户当天在外高桥港区未离港的预约 + * + * @param users_id 用户id + * @param port_area_id 港区id + * @param approach_date 进港日期 + * @return 返回预约信息 + */ + @Override + public Appointment getAppointmentByUserIdAndPortAreaIdAndApproachDate(String users_id, String port_area_id, String approach_date) { + return appointmentMapper.getAppointmentByUserIdAndPortAreaIdAndApproachDate(users_id, port_area_id, approach_date); + } + + /** + * 修改预约板车扫描时间及预约状态(预约状态进入收车状态,就不能取消,但可以修改) + * + * @param appointment_id 预约id + * @return 返回结果 + */ + @Override + public Integer updateAppointmentPlateScanTime(String appointment_id) { + //板车扫描时间: 如果未进港,改成已进港,同时记录进港时间 + Appointment appointment = appointmentMapper.getById(appointment_id); + if (appointment == null) { + return 0; + } + Date now = new Date(); + //签到时间 + if (appointment.getCheck_in_time() == null || appointment.getCheck_in_time().isEmpty()) { + appointment.setCheck_in_time(FormatDateTime.dateTimeToStr(now)); + } + //进闸口时间 + if (appointment.getGate_canal_in_time() == null || appointment.getGate_canal_in_time().isEmpty()) { + appointment.setGate_canal_in_time(FormatDateTime.dateTimeToStr(now)); + } + //收车扫描,状态可以改为作业中(5) + if (appointment.getAppointment_state() < 5) { + appointment.setAppointment_state(5); + } + //收车扫描时间 + appointment.setPlate_scan_time(FormatDateTime.dateTimeToStr(now)); + + int res = appointmentMapper.update(appointment); + //完善签到打卡(),将打卡表状态修改为,作业中状态 + if (res > 0) { + PunchClock punchClock = punchClockMapper.getPunchClockByAppointmentId(appointment_id); + if (punchClock != null) { + String start_time = punchClock.getStart_time(); + String queue_number = punchClock.getQueue_number(); + String punch_address = punchClock.getPunch_address(); + Integer punch_clock_type = punchClock.getPunch_clock_type(); + if (start_time == null || start_time.isEmpty()) { + start_time = FormatDateTime.dateTimeToStr(now); + punchClock.setStart_time(start_time); + } + if (queue_number == null || queue_number.isEmpty()) { + String last_queue_number = punchClockExtendMapper.getLastQueueNumber(now, appointment.getPort_area_id()); + //生成新的排队编号 + //排队号需求变更,格式"2308210001" + queue_number = QueueNumberHelper.getNewQueueNumber(last_queue_number); + punchClock.setQueue_number(queue_number); + } + if (punch_address == null || punch_address.isEmpty()) { + PortArea portArea = portAreasMapper.getById(appointment.getPort_area_id()); + if (portArea != null) { + punchClock.setPunch_address(portArea.getPort_area_address()); + } + } + //扫码收车,可以设置打卡状态为操作中(3) + punchClock.setPunch_clock_type(3); + punchClock.setUpdate_time(FormatDateTime.dateTimeToStr(now)); + int x = punchClockMapper.update(punchClock); + } + } + return res; + + } + + @Override + public List getAppointmentDetailListByGoodVinList(List vinlist) { + return appointmentDetailMapper.getAppointmentDetailListByGoodVinList(vinlist); + } + + /** + * 根据 Vin列表查询匹配的商品车明细,并筛选出不属于已取消和异常的预约的 + * + * @param vinlist vinlist + * @return vinlist + */ + @Override + public List getAppointmentDetailListByVinList(List vinlist, String appointmentId) { + //获取与vinList匹配的商品车明细 + List detailList = appointmentDetailMapper.getAppointmentDetailListByVinList(vinlist); + //获得所有有效预约id集合 + List mylist = appointmentMapper.getIdListNoInEnNew(); + List resdetailList = null; + if (detailList != null && detailList.size() > 0) { + //排除掉当前预约自身的明细 + if (appointmentId != null && !appointmentId.isEmpty()) { + detailList = Linq.of(detailList).where(p -> !appointmentId.equals(p.getAppointment_id())).toList(); + } + if (mylist != null && mylist.size() > 0) { + resdetailList = Linq.of(detailList).where(p -> mylist.contains(p.getAppointment_id())).toList(); + } + } + return resdetailList; + } + + @Override + public Integer deleteAppointmentDetailByAppointmentId(String appointment_id) { + return appointmentDetailMapper.deleteAppointmentDetailByAppointmentId(appointment_id); + } + + /** + * 激活验证,返回商品企业信息 + * + * @param vinList vin + * @return 激活验证,返回商品企业信息 + */ + @Override + public List validCusVin(List vinList) { + if (vinList == null || vinList.size() == 0) { + return null; + } + List list = null; + try { + ValidRequest validRequest = new ValidRequest(); + validRequest.setVins(vinList); + com.haitongauto.models.res.Response> myResponse = cusOrderApi.getCheckVinISValid(validRequest); + list = myResponse.getData(); + logger.info("激活验证回复:" + JSON.toJSONString(list)); + } catch (Exception e) { + logger.info(e.getMessage()); + logger.info("激活验证回复:" + JSON.toJSONString(e.getMessage())); + throw new RuntimeException("激活验证回复:" + e); + } + return list; + } + + /** + * 获得需要传送哪吒的智云参数 + * + * @param validCusVinList + * @return 返回结果 + */ + @Override + public List cargoInfoNaz(List validCusVinList, String truckNum) { + List list = null; + if (validCusVinList == null || validCusVinList.size() == 0) { + return null; + } + if (truckNum == null || truckNum.isEmpty()) { + return null; + } + Truck truck = truckMapper.getPalletTruckByTruckNo(truckNum); + //获得所有记录的企业编号,按企业编号分组 + List companyCodeList = Linq.of(validCusVinList).select(p -> p.getCompanyCode()).distinct().toList(); + if (companyCodeList != null && companyCodeList.size() > 0) { + list = new ArrayList<>(); + for (String companyCode : companyCodeList) { + EnterpriseInfo enterpriseInfo = new EnterpriseInfo(); + CargoInfo cargoInfo = new CargoInfo(); + if (truck != null) { + cargoInfo.setVehicleNo(truckNum); + cargoInfo.setVehicleFrameWt(truck.getVehicle_frame_weight().toString()); + cargoInfo.setVehicleWt(truck.getVehicle_weight().toString()); + } + List goodList = new ArrayList<>(); + List validCusVinList_comp = Linq.of(validCusVinList).where(p -> p.getCompanyCode().equals(companyCode)).toList(); + if (validCusVinList_comp != null && validCusVinList_comp.size() > 0) { + ValidCusVin validCusVin_first = Linq.of(validCusVinList_comp).firstOrDefault(); + enterpriseInfo.setNumber(validCusVin_first.getCompanyCode()); + enterpriseInfo.setCode(validCusVin_first.getCompanySocialCode()); + enterpriseInfo.setName(validCusVin_first.getCompanyName()); + enterpriseInfo.setCountry(validCusVin_first.getCountry()); + enterpriseInfo.setCity(validCusVin_first.getCity()); + for (ValidCusVin vin : validCusVinList_comp) { + Good good = new Good(); + good.setGdsMtno(vin.getCargoItemNo()); + good.setGdecd(vin.getCargoCode()); + good.setGdsNm(vin.getCargoName()); + good.setGdsSpcfModelDesc(vin.getSpec()); + good.setDclCurrcd(vin.getCurrency()); + good.setDclTotalAmt(vin.getTotalPrice()); + good.setNetWt(vin.getNetWeight()); + good.setDclUnitcd(vin.getUnitMeasure()); + good.setUnit1(vin.getUnitLegal());//该字段后一个字母是 数字1还是字母l; + good.setNatcd(vin.getOriginArea()); + good.setVin(vin.getVin()); + goodList.add(good); + } + } + CargoInfoNaz cargoInfoNaz = new CargoInfoNaz(); + cargoInfoNaz.setCargoInfo(cargoInfo); + cargoInfoNaz.setEnterpriseInfo(enterpriseInfo); + cargoInfoNaz.setGoodsInfo(goodList); + cargoInfoNaz.setPushType("oneByOne");//王正琰 写死 + list.add(cargoInfoNaz); + } + } + return list; + } +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ForwardServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ForwardServiceImpl.java new file mode 100644 index 0000000..e6c117d --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ForwardServiceImpl.java @@ -0,0 +1,287 @@ +package com.haitongauto.rtosac.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.haitongauto.mapper.base.PortAreasMapper; +import com.haitongauto.mapper.base.TruckMapper; +import com.haitongauto.mapper.base.UsersMapper; +import com.haitongauto.models.forward.*; +import com.haitongauto.models.pojo.*; + +import com.haitongauto.rtosac.service.ForwardService; +import com.haitongauto.utils.HttpClientHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +@Service +@EnableAsync +public class ForwardServiceImpl implements ForwardService { + private static final Logger logger = LogManager.getLogger(ForwardServiceImpl.class); + @Autowired + UsersMapper usersMapper; + @Autowired + PortAreasMapper portAreasMapper; + + @Autowired + TruckMapper truckMapper; + + + /** + * 预约信息完成,将完成状态同步到老系统(整车物流) + * + * @param appointOverState 预约完成转态 + * @return + */ + @Override + @Async + public CompletableFuture appointmentOverApiAsync(AppointOverState appointOverState) { + return CompletableFuture.supplyAsync(() -> { + try { + return appointmentOverApi(appointOverState); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + }); + } + + /** + * 预约信息完成,将完成状态同步到老系统(整车物流) + * + * @param appointOverState 预约完成转态 + * @return + */ + private ForwardRes appointmentOverApi(AppointOverState appointOverState) throws IOException, CloneNotSupportedException { + if (appointOverState == null) { + return null; + } + String myUrl = "http://192.168.161.81:8090/rtopswebapi/api/NsOrder/execTruckOrderOsFin"; + //调用哪吒接口,将预约完成转态,同步老系统 + //ForwardConfig config = ConfigHelper.getForwardConfig(); + //if (config != null) { + // myUrl = config.getUrl() + "execTruckOrderOsFin"; + //} + ForwardRes forwardRes = null; + logger.info("预约完成状态,同步老系统:"+JSON.toJSONString(appointOverState)); + String res = HttpClientHelper.forwardSendNew(appointOverState, myUrl); + + + if (res != null && res.contains("success")) { + forwardRes = JSONObject.parseObject(res, ForwardRes.class); + } + logger.info("预约完成状态,同步老系统,返回:"+res); + return forwardRes; + + } + + + /*** + * 预约信息异步转发到老系统 + * @param + * @return 返回进港 + */ + @Override + @Async + public CompletableFuture invokeApiAsyncForward(Appointment appointment, List appointmentDetailList) { + return CompletableFuture.supplyAsync(() -> { + try { + return invokeForwardApi(appointment, appointmentDetailList); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + }); + } + + /*** + * 预约信息异步转发到老系统 + * @param + * @return 返回进港 + */ + private ForwardRes invokeForwardApi(Appointment appointment, List appointmentDetailList) throws IOException, CloneNotSupportedException { + if (appointment == null) { + return null; + } + AppointForward appointForward = new AppointForward(); + //appointForward.setId(appointment.getId());//预约id + appointForward.setTruckNo(appointment.getTruck_number());//板车号 + appointForward.setPhone(appointment.getTel_number());//手机号码 + appointForward.setGodNum(appointment.getGoods_quantity());//货物数量 + appointForward.setOrderTm(appointment.getApproach_date());//预约时间 + Users users = usersMapper.getById(appointment.getUsers_id()); + if (users != null) { + appointForward.setOpenId(users.getWx_openid());//openid + } + PortArea portArea = portAreasMapper.getById(appointment.getPort_area_id()); + if (portArea != null) { + appointForward.setWhafType(portArea.getPort_area_name());//港区 + } + String goods_type = appointment.getGoods_type(); + //货物类型 + if (goods_type != null && !goods_type.isEmpty()) { + switch (goods_type) { + case "C": { + appointForward.setGodType("商品车"); + break; + } + case "L": { + appointForward.setGodType("大件"); + break; + } + case "M": { + appointForward.setGodType("工程机械"); + break; + } + } + } + + //进港类型 + String enter_type = appointment.getEnter_type(); + if (enter_type != null && !enter_type.isEmpty()) { + switch (enter_type) { + case "WE": { + appointForward.setOrderType("外贸出口"); + break; + } + case "WI": { + appointForward.setOrderType("外贸进口"); + break; + } + case "NE": { + appointForward.setOrderType("内贸出口"); + break; + } + case "NI": { + appointForward.setOrderType("内贸进口"); + break; + } + case "BC": { + appointForward.setOrderType("奔驰分拨"); + break; + } + case "LP": { + appointForward.setOrderType("提离港区"); + break; + } + case "BM": { + appointForward.setOrderType("宝马分拨"); + break; + } + case "JL": { + appointForward.setOrderType("捷豹路虎分拨"); + break; + } + case "AC": { + appointForward.setOrderType("安盛场地"); + break; + } + case "FT": { + appointForward.setOrderType("丰田分拨"); + break; + } + case "AD": { + appointForward.setOrderType("奥迪分拨"); + break; + } + case "OTHER": { + appointForward.setOrderType("其他品牌分拨"); + break; + } + case "MV": { + appointForward.setOrderType("移库短驳"); + break; + } + } + } + + List vinDetails = null; + if (appointmentDetailList != null && appointmentDetailList.size() > 0) { + vinDetails = new ArrayList<>(); + for (AppointmentDetail appointmentDetail : appointmentDetailList) { + VinDetail vinDetail = new VinDetail(); + vinDetail.setVin(appointmentDetail.getVin());//车架号 + String shipName = appointmentDetail.getShip_name(); + if (shipName != null && !shipName.isEmpty()) { + String myShipName = shipName.split("/")[0]; + vinDetail.setVlsNm(myShipName);//船名 + } + String brandName = appointmentDetail.getBrand_name(); + if (brandName != null && !brandName.isEmpty()) { + String myBrandName = brandName.split("/")[0]; + vinDetail.setBrdNm(myBrandName);//品牌 + } + String destinationPort = appointmentDetail.getDestination_port(); + if (destinationPort != null && !destinationPort.isEmpty()) { + String myDestinationPort = destinationPort.split("/")[0]; + vinDetail.setPotNm(myDestinationPort);//港口 + } + vinDetails.add(vinDetail); + } + } + appointForward.setDataList(vinDetails); + + //调用哪吒接口,将预约数据转发到,老系统,待补充 + String myUrl = "http://192.168.161.81:8090/rtopswebapi/api/NsOrder/execTruckOrder"; + ForwardRes forwardRes = null; + //ForwardConfig config= ConfigHelper.getForwardConfig(); + //if (config != null) { + // myUrl = config.getUrl() + "execTruckOrder"; + //} + logger.info("预约信息转发:"+JSON.toJSONString(appointForward)); + String res = HttpClientHelper.forwardSendNew(appointForward, myUrl); + + + if (res != null && res.contains("success")) { + forwardRes = JSONObject.parseObject(res, ForwardRes.class); + } + logger.info("预约信息转发回复:"+res); + return forwardRes; + } + + + @Override + public Integer execUserTruck(List userTrucks) { + Integer res = 0; + if (userTrucks != null && userTrucks.size() > 0) { + for (UserTruck item : userTrucks) { + //用户 + Users users = new Users(); + users.setUsers_name(item.getUsers_name()); + users.setId(item.getUsers_id()); + users.setWx_openid(item.getWx_openid()); + users.setTel_number(item.getTel_number()); + users.setId_code(item.getId_code()); + String wx_openid = item.getWx_openid(); + Users myUsers = null; + if (wx_openid != null && !wx_openid.isEmpty()) { + myUsers = usersMapper.getByWxOpenid(wx_openid); + } + + if (myUsers != null) { + users.setId(myUsers.getId()); + usersMapper.update(users); + res = res + 1; + + } else { + usersMapper.insert(users); + } + } + + } + Users users = new Users(); + return null; + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/HomeServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/HomeServiceImpl.java new file mode 100644 index 0000000..4b06dfc --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/HomeServiceImpl.java @@ -0,0 +1,540 @@ +package com.haitongauto.rtosac.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.bestvike.linq.Linq; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.haitongauto.interfaces.OrderApi; +import com.haitongauto.interfaces.UserInterface; +import com.haitongauto.mapper.base.*; +import com.haitongauto.models.ido.CommonRes; +import com.haitongauto.models.ido.login.UserLoginOrRegisterRequest; +import com.haitongauto.models.ido.login.PostLoginRes; +import com.haitongauto.models.ido.login.UserLoginOrRegisterResponse; +import com.haitongauto.models.pojo.*; +import com.haitongauto.models.pojo.Announcement; +import com.haitongauto.models.sysuser.OldSysTruck; +import com.haitongauto.models.sysuser.OldSysUser; +import com.haitongauto.rtosac.service.HomeService; +import com.haitongauto.models.dto.DataForMessage; +import com.haitongauto.utils.FormatDateTime; +import com.haitongauto.utils.HttpRequest; +import com.haitongauto.mapper.client.OtherExtendMapper; +import com.haitongauto.utils.HttpTemplate; +import com.haitongauto.utils.StringHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.*; + +@Service +public class HomeServiceImpl implements HomeService { + + @Autowired + AnnouncementMapper announcementsMapper; + @Autowired + UsersMapper usersMapper; + @Autowired + TruckMapper truckMapper; + @Autowired + ServiceConfigMapper serviceConfigMapper; + @Autowired + RequesterMapper requesterMapper; + @Autowired + OtherExtendMapper otherExtendMapper; + @Autowired + LoginLogMapper loginLogMapper; + @Autowired + UserInterface userInterface; + private String users_id; + @Resource + OrderApi orderApi; + + @Override + public void userInfoSync1(OldSysUser applet_users, OldSysTruck applet_truck) { + Users users = new Users(); + users.setId(applet_users.getId()); + users.setUsers_name(applet_users.getUsers_name()); + users.setTel_number(applet_users.getTel_number()); + users.setWx_openid(applet_users.getWx_openid()); + users.setUsers_state(1); + users.setIs_del(0); + Users myUsers = usersMapper.getByWxOpenid(users.getWx_openid()); + if (myUsers == null) { + usersMapper.insert(users); + } else { + users.setId(myUsers.getId()); + usersMapper.update(users); + } + + Truck truck = new Truck(); + truck.setId(applet_truck.getId()); + truck.setUsers_id(applet_truck.getUsers_id()); + truck.setTruck_number(applet_truck.getTruck_number()); + truck.setTel_number(applet_truck.getTel_number()); + truck.setWx_openid(applet_truck.getWx_openid()); + truck.setTruck_state(1); + truck.setIs_del(0); + Truck myTruck = truckMapper.getTruckByOpenId(applet_truck.getWx_openid()); + if (myTruck == null) { + truckMapper.insert(truck); + } else { + truck.setId(myTruck.getId()); + truckMapper.update(truck); + } + + } + + + @Override + public Users userInfoSync(String wx_openid, String tel_number) { + Users users = new Users(); + Users myUsers = usersMapper.getByWxOpenid(wx_openid); + if (myUsers != null) { + users.setId(myUsers.getId()); + users.setWx_openid(wx_openid); + users.setTel_number(tel_number); + users.setUsers_state(0); + users.setIs_del(0); + + myUsers.setWx_openid(wx_openid); + myUsers.setTel_number(tel_number); + + usersMapper.update(users); + + Truck truck = new Truck(); + Truck myTruck = truckMapper.getTruckByOpenId(wx_openid); + if (myTruck != null) { + truck.setId(myTruck.getId()); + truck.setWx_openid(wx_openid); + truck.setTel_number(tel_number); + truck.setTruck_state(1); + truck.setIs_del(0); + truckMapper.update(truck); + } + + } else { + return null; + } + + + return myUsers; + } + + /** + * 根据id查询用户 + * + * @param id 用户id + * @return 返回用户 + */ + @Override + public Users getUsersForId(String id) { + return (Users) usersMapper.getById(id); + } + + /** + * 根据用户的小程序 openid 获取用户在数据库里的数据 + * + * @param wx_openid 微信openid + * @return 返回用户信息 + */ + @Override + public Users getUsersForOpenId(String wx_openid) { + return otherExtendMapper.getUsersForOpenId(wx_openid); + } + + /** + * 用户登录 + * + * @param users 用户 + * @return 返回执行结果 + */ + @Override + public PostLoginRes postLogin(Users users) { + //初始变量 + String users_id = users.getId(); + String truck_id = ""; + String access_token_rtos = ""; + PostLoginRes postLoginRes = new PostLoginRes(); + //将用户信息提交给哪吒 哪吒入参 + String appId = ""; + appId = getServiceConfigForCode("400"); + String mobile = users.getTel_number(); + String openId = users.getWx_openid(); + String unionId = users.getWx_unionid(); + + //请求哪吒注册登录 + if (true) { + UserLoginOrRegisterRequest request = new UserLoginOrRegisterRequest(); + request.setAppId(appId); + request.setMobile(mobile); + request.setOpenId(openId); + request.setUnionId(unionId); + request.setMediaType("小程序"); + //用户信息提交外部接口(哪吒) 返回参数缺少userId,需要补充 + //本地测试注释,正式环境需要解开 + CommonRes myResponse = orderApi.login(request); + if (myResponse != null) { + UserLoginOrRegisterResponse response = myResponse.getData(); + if (response != null) { + access_token_rtos = response.getAccess_token(); + System.out.print("Rtos登录注册接口Token:" + access_token_rtos); + } + } + } + + String date = FormatDateTime.dateTimeToStr(new Date()); + //添加用户司机信息 + if (!Objects.equals(users.getWx_openid(), "")) { + Users myusers = this.getUsersForOpenId(openId); + if (myusers != null) { + users.setId(myusers.getId()); + users.setIs_del(0); + users.setAccess_token(myusers.getAccess_token()); + } + String users_name = users.getUsers_name(); + users.setWx_nick(users_name); + users.setCreate_time(date); + users.setUpdate_time(date); + users.setUsers_state(0); + users.setAccess_token_rtos(access_token_rtos); + users.setIs_del(0); + + if (users.getId() == null || users.getId().isEmpty()) { + users.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase()); + //更新到数据库,返回当前id + users_id = usersMapper.insert(users); + } else { + Integer x = usersMapper.update(users); + } + } + postLoginRes.setUsers_id(users_id); + postLoginRes.setTruck_id(truck_id); + postLoginRes.setAccess_token_rtos(access_token_rtos); + + return postLoginRes; + } + + /** + * 用户登录 + * + * @param truck 板车 + * @return 返回执行结果 + */ + @Override + public String insertTruck(Truck truck) { + String id = truck.getId(); + if (id == null || id.isEmpty()) { + id = UUID.randomUUID().toString().replace("-", "").toLowerCase(); + truck.setId(id); + id = truckMapper.insert(truck); + } + return id; + } + + /** + * 用户登录 + * + * @param truck 板车 + * @return 返回执行结果 + */ + @Override + public Integer updateTruck(Truck truck) { + Integer x = truckMapper.update(truck); + return x; + } + + /** + * 写入登录日志 + * + * @param wx_openid wx_openid + * @param ip ip地址 + */ + @Override + public void loginLogAdd(String wx_openid, String ip) { + //获取IP所在的城市,异步调用外部接口 + String url = "http://ip.360.cn/IPQuery/ipquery?ip=" + ip; + new Thread(new Runnable() { + @Override + public void run() { + int i = 0; + String res = HttpTemplate.doGet(url); + while (res.isEmpty()) { + res = HttpTemplate.doGet(url); + i++; + if (i > 20 && res.isEmpty()) { + return; + } + } + Map maps = (Map) JSON.parse(res); + String area = maps.get("data").toString().split("\t")[0]; + //控制台打印 + System.out.println(maps.get("data").toString().split("\t")[0]); + //数据封装到LoginLog + String date = FormatDateTime.dateTimeToStr(new Date()); + LoginLog loginLog = new LoginLog(); + loginLog.setWx_openid(wx_openid); + loginLog.setIp(ip); + loginLog.setArea(area); + loginLog.setLogin_time(date); + loginLog.setCreate_time(date); + loginLog.setUpdate_time(date); + loginLog.setIs_del(0); + String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase(); + loginLog.setId(uuid); + //写入数据库 + loginLogMapper.insert(loginLog); + } + }).start(); + } + + /** + * 分页读取每页10条公告数据 + * + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回分页数据 + */ + @Override + public PageInfo getAnnouncementsList(Integer pageNum, Integer pageSize, Integer sort, String keyWords) { + //初始化PageHelper + PageHelper.startPage(pageNum, pageSize, true, false, false); + //立即查询 + List mylist = announcementsMapper.getListBySort(sort, keyWords); + if (mylist != null && mylist.size() > 0) { + for (Announcement item : mylist) { + String announcement = item.getAnnouncement(); + String announcement_text = ""; + if (announcement != null && !announcement.isEmpty()) { + announcement_text = StringHelper.getTxtByHtml(announcement); + } + item.setAnnouncement_text(announcement_text); + + + } + } + + //获取分页数据 + + assert mylist != null; + return new PageInfo(mylist); + } + + /** + * 根据公告id获得公告 + * + * @param announcement_id 公告id + * @return 返回公告信息 + */ + @Override + public Announcement getAnnouncementById(String announcement_id) { + Announcement announcement = null; + announcement = announcementsMapper.getById(announcement_id); + String announcementStr = null; + if (announcement != null) { + announcementStr = announcement.getAnnouncement(); + } + String announcement_text = ""; + if (announcementStr != null && !announcementStr.isEmpty()) { + announcement_text = StringHelper.getTxtByHtml(announcementStr); + announcement.setAnnouncement_text(announcement_text); + } + return announcement; + } + + /** + * 读取系统服务路径 + * + * @return 返回系统服务路径 + */ + @Override + public String getServiceBaseUrl() { + List mylist = serviceConfigMapper.getList(); + String servicePath = ""; + if (mylist != null && mylist.size() > 0) { + servicePath = mylist.stream().filter(a -> a.getConfig_code().equals("100")).findFirst().get().getConfig_content(); + } + + return servicePath; + } + + /** + * 读取图片访问路径 + * + * @return 返回图片路径 + */ + @Override + public String getImgAccessUrl() { + List mylist = serviceConfigMapper.getList(); + String imgServicePath = ""; + if (mylist != null && mylist.size() > 0) { + ServiceConfig serviceConfig = Linq.of(mylist).firstOrDefault(p -> p.getConfig_code().equals("300")); + if (serviceConfig != null) { + imgServicePath = serviceConfig.getConfig_content(); + } + } + return imgServicePath; + } + + /** + * 根据配置编号获取配置值 + * + * @param config_code 配置编号 + * @return 返回配置值 + */ + @Override + public String getServiceConfigForCode(String config_code) { + return otherExtendMapper.getServiceConfigForCode(config_code); + } + + /** + * 获取外部接口数据 + * + * @param request_type : 请求类型参数,取值于Requester表 + * @param myParamMap :实时传值,其键值对与 Requester表param字段的键值对对应 + * @return 返回外部接口数据 + */ + @Override + public String getExternalInterfaceData(Integer request_type, Map myParamMap) { + //根据请求类型获取一条请求配置数据 + Requester requester = otherExtendMapper.getRequesterForType(request_type); + //解析请求配置 + String url = requester.getUrl(); + StringBuilder param = new StringBuilder(); + Map paramMap = JSONObject.parseObject(requester.getParam_map()); + if (requester.getParam_map() != null && !requester.getParam_map().isEmpty()) { + for (Map.Entry item : paramMap.entrySet()) { + String key = item.getKey(); + Object value; + //遍历配置参数 + if (item.getValue().equals("")) { + value = myParamMap.get(key); //当key的value为空字符串时,key参数取值myParamMap传值中的key对应的值 + } else { + value = item.getValue(); //当key与value不相等时,key参数取值value + } + param.append((param.toString().equals("")) ? key + "=" + value : "&" + key + "=" + value); + } + } + + //发送请求 + String dataJson = ""; + try { + dataJson = HttpRequest.sendGet(url, param.toString()); + } catch (Exception e) { + System.out.println("请求异常!" + e); + e.printStackTrace(); + } + return dataJson; + } + + /** + * 发送订阅消息 + * + * @param dataForMessage:订阅消息发送数据类的实例 + * @return 发送失败的错误信息 + */ + @Override + public String sendMessage(DataForMessage dataForMessage) { + /* + //解析订阅消息发送数据类的实例 + String access_token = dataForMessage.getAccess_token(); //接口调用凭证,该参数为 URL 参数,非 Body 参数。使用access_token或者authorizer_access_token + String template_id = dataForMessage.getTemplate_id(); //所需下发的订阅模板id + String page = dataForMessage.getPage(); //点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转 + String touser = dataForMessage.getTouser(); //接收者(用户)的 openid + String data = dataForMessage.getData(); //模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }的object + String miniprogram_state = dataForMessage.getMiniprogram_state(); //跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 + */ + //请求参数 + String access_token = dataForMessage.getAccess_token(); + String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + access_token; + String param = JSON.toJSONString(dataForMessage); + + //发送请求(参考微信官方:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/sendMessage.html) + String dataJson = ""; + try { + dataJson = HttpRequest.sendPost(url, param); + } catch (Exception e) { + System.out.println("请求异常!" + e); + e.printStackTrace(); + } + return dataJson; + } + + /** + * 返回文件后缀 + * + * @param file 文件 + * @return 返回文件后缀 + */ + @Override + public String getImagePath(MultipartFile file) { + String fileName = (file != null) ? file.getOriginalFilename() : "";//获取原文件名 + int index; + if ((!Objects.equals(fileName, ""))) { + assert fileName != null; + index = fileName.indexOf("."); + } else { + index = 0; + } + return fileName.substring(index); + } + + /** + * 保存图片 + * + * @param mfile 文件 + * @param file 文件 + * @return 返回执行结果 + */ + @Override + public boolean saveImage(MultipartFile mfile, File file) { + //查看文件是否存在,不存在则创建 + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + try { + //使用此方法保存必须要绝对路径且文件夹必须已存在,否则报错 + mfile.transferTo(file); + return true; + } catch (IllegalStateException | IOException e) { + e.printStackTrace(); + } + return false; + } + + /** + * 新文件名 + * + * @param suffix suffix + * @return 返回文件名 + */ + @Override + public String getNewFileName(String suffix) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String date = sdf.format(new Date()); + return date + UUID.randomUUID() + suffix; + } + + /** + * 返回图片保存地址 + * + * @param name 文件名 + * @return 返回图片保存地址 + */ + @Override + public String getNewImagePath(String name) { + List mylist = serviceConfigMapper.getList(); + String imgPath = ""; + if (mylist != null && mylist.size() > 0) { + imgPath = mylist.stream().filter(a -> a.getConfig_code().equals("200")).findFirst().get().getConfig_content(); + } + return imgPath + "/" + name; + } + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MessageServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MessageServiceImpl.java new file mode 100644 index 0000000..94dd354 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MessageServiceImpl.java @@ -0,0 +1,241 @@ +package com.haitongauto.rtosac.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.haitongauto.mapper.base.*; +import com.haitongauto.models.pojo.*; +import com.haitongauto.rtosac.service.MessageService; +import com.haitongauto.rtosac.service.UsersService; +import com.haitongauto.utils.FormatDateTime; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +@Service +public class MessageServiceImpl implements MessageService { + @Autowired + MessageMapper messageMapper; + @Autowired + UsersMapper usersMapper; + @Autowired + PortAreasMapper portAreasMapper; + @Autowired + TruckMapper truckMapper; + @Autowired + AppointmentMapper appointmentMapper; + @Autowired + PunchClockMapper punchClockMapper; + + @Override + public String insert(Message message) { + return messageMapper.insert(message); + } + + @Override + public int update(Message message) { + return messageMapper.update(message); + } + + /** + * @param message 消息实体 + * @return 返回结果 + */ + @Override + public boolean receiveMessage(Message message) { + boolean b = false; + if (message == null) { + return b; + } + Message myMessage = null; + Integer type = message.getType(); + String biz_id = message.getBiz_id(); + myMessage = messageMapper.getLastMessageByTypeAndBizId(type, biz_id); + if (myMessage == null) { + message.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase()); + String id = messageMapper.insert(message); + if (id != null && !id.isEmpty()) { + b = true; + } + } else { + message.setId(myMessage.getId()); + int id = messageMapper.update(message); + if (id > 0) { + b = true; + } + } + return b; + } + + /** + * 获得车辆最新消息 + * + * @param type 收车/发车 + * @param biz_id biz_id + * @return 返回消息 + */ + @Override + public Message getLastMessageByTypeAndBizId(Integer type, String biz_id) { + return messageMapper.getLastMessageByTypeAndBizId(type, biz_id); + } + + /** + * 获得未读消息 包含 车牌号和身份证号(自开) + * + * @param wxOpenid 微信openid + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回结果 + */ + @Override + public PageInfo getUnReadMessageListByWxOpenid(String wxOpenid, Integer pageNum, Integer pageSize) { + List messageList = null; + Truck truck = truckMapper.getTruckByOpenId(wxOpenid); + Users users = usersMapper.getByWxOpenid(wxOpenid); + List truckNums = new ArrayList<>(); + String truck_number = null; + String id_code = null; + if (truck != null) { + truck_number = truck.getTruck_number(); + if (truck_number != null && !truck_number.isEmpty()) { + truckNums.add(truck_number); + } + } + if (users != null) { + id_code = users.getId_code(); + if (id_code != null && !id_code.isEmpty()) { + truckNums.add(id_code); + } + } + if (truckNums != null && truckNums.size() > 0) { + PageHelper.startPage(pageNum, pageSize, true, false, false); + messageList = messageMapper.getUnReadMessageListByTruckNumber(truckNums); + } + if (messageList == null) { + messageList = new ArrayList<>(); + } + return new PageInfo<>(messageList); + + } + + /** + * 获得站内消息 包含 车牌号和身份证号(自开) + * @param wxOpenid 微信openid + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回结果 + */ + @Override + public PageInfo getMessageListByWxOpenid(String wxOpenid, Integer pageNum, Integer pageSize) { + List messageList = null; + Truck truck = truckMapper.getTruckByOpenId(wxOpenid); + Users users = usersMapper.getByWxOpenid(wxOpenid); + List truckNums = new ArrayList<>(); + String truck_number = null; + String id_code = null; + if (truck != null) { + truck_number = truck.getTruck_number(); + if (truck_number != null && !truck_number.isEmpty()) { + truckNums.add(truck_number); + } + } + if (users != null) { + id_code = users.getId_code(); + if (id_code != null && !id_code.isEmpty()) { + truckNums.add(id_code); + } + } + if (truckNums != null && truckNums.size() > 0) { + PageHelper.startPage(pageNum, pageSize, true, false, false); + messageList = messageMapper.getMessageListByTruckNumber(truckNums); + } + if (messageList == null) { + messageList = new ArrayList<>(); + } + return new PageInfo<>(messageList); + + } + + /** + * 微信小程序前端打开界面,获得所有未读消息数量 包含车牌号和身份证号(自开) + * + * @param wxOpenid 微信openId + * @return 返回结果 + */ + @Override + public Integer sumUnread(String wxOpenid) { + Truck truck = truckMapper.getTruckByOpenId(wxOpenid); + Users users = usersMapper.getByWxOpenid(wxOpenid); + List truckNums = new ArrayList<>(); + String truck_number = null; + String id_code = null; + if (truck != null) { + truck_number = truck.getTruck_number(); + if (truck_number != null && !truck_number.isEmpty()) { + truckNums.add(truck_number); + } + } + if (users != null) { + id_code = users.getId_code(); + if (id_code != null && !id_code.isEmpty()) { + truckNums.add(id_code); + } + } + Integer result = 0; + if (truckNums != null && truckNums.size() > 0) { + result = messageMapper.sumUnread(truckNums); + } + + return result; + } + + /** + * 通过打印小票环节完成完工打卡 + * + * @param appointmentId 预约id + */ + @Override + public Appointment punchClockOverByPrint(String appointmentId) { + if (appointmentId == null || appointmentId.isEmpty()) { + return null; + } + //获取当前日期时间 + Date datetime = new Date(); + Integer res = 0; + //更新预约状态 + Appointment appointment = appointmentMapper.getById(appointmentId); + if (appointment != null) { + //appointment.setAppointment_state(6); + //完成打印小票就直接设置成(离港状态)郑璐、张小雅 + appointment.setAppointment_state(7); + appointment.setCheck_over_time(FormatDateTime.dateTimeToStr(datetime)); + appointment.setGate_canal_out_time(FormatDateTime.dateTimeToStr(datetime)); + appointment.setUpdate_time(FormatDateTime.dateTimeToStr(datetime)); + res = appointmentMapper.update(appointment); + } + //更新打卡状态为完成状态 + PunchClock punchClock = punchClockMapper.getPunchClockByAppointmentId(appointmentId); + if (punchClock != null) { + punchClock.setOver_time(FormatDateTime.dateTimeToStr(datetime)); + String portAreaId = punchClock.getPort_area_id(); + PortArea portArea = null; + if (portAreaId != null && !portAreaId.isEmpty()) { + portArea = portAreasMapper.getById(punchClock.getPort_area_id()); + } + if (portArea != null) { + punchClock.setOver_address(portArea.getPort_area_address()); + } + punchClock.setPunch_clock_type(4); + punchClock.setUpdate_time(FormatDateTime.dateTimeToStr(datetime)); + punchClockMapper.update(punchClock); + } + return appointment; + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MineServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MineServiceImpl.java new file mode 100644 index 0000000..f194899 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MineServiceImpl.java @@ -0,0 +1,354 @@ +package com.haitongauto.rtosac.service.impl; + + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.haitongauto.interfaces.UsersApi; +import com.haitongauto.mapper.base.*; +import com.haitongauto.models.ido.CommonRes; +import com.haitongauto.models.ido.login.UserInfoRes; +import com.haitongauto.models.pojo.*; +import com.haitongauto.rtosac.service.MineService; +import com.haitongauto.mapper.client.OtherExtendMapper; +import com.haitongauto.mapper.client.TruckExtendMapper; +import com.haitongauto.mapper.client.AppointmentExtendMapper; +import com.haitongauto.utils.FormatDateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.util.*; + +@Service +public class MineServiceImpl implements MineService { + @Autowired + UsersMapper usersMapper; + @Autowired + TruckMapper truckMapper; + @Autowired + FeedbackMapper feedbackMapper; + @Autowired + AppointmentMapper appointmentMapper; + @Autowired + NoviceIntroductionMapper noviceIntroductionMapper; + @Autowired + AppointmentDetailMapper appointmentDetailMapper; + @Autowired + OtherExtendMapper otherExtendMapper; + @Autowired + TruckExtendMapper truckExtendMapper; + @Autowired + AppointmentExtendMapper appointmentExtendMapper; + @Resource + private UsersApi usersApi; + + /** + * 个人资料修改 + * + * @param users 用户(司机) + * @return 返回修改结果 + */ + @Override + public Integer postMyUsers(Users users) { + String users_id = users.getId(); + Integer x = (users_id != null && users_id.length() > 0) ? usersMapper.update(users) : null; + return x; + } + + /** + * 获取我的板车信息 + * + * @param truckId 板车id + * @return 返回我的板车信息 + */ + @Override + public Truck getTruck(String truckId) { + return truckMapper.getById(truckId); + } + + /** + * 获取我的板车信息 + * + * @param users_id 司机id + * @return 返回我的板车信息 + */ + @Override + public List getMyPalletTruck(String users_id) { + //访问哪吒接口,先获取并更新我的车辆可能被列入黑名单的信息 + List myTruckManagementList = truckExtendMapper.getMyTruckManagement(users_id); + if (myTruckManagementList != null && myTruckManagementList.size() > 0) { + for (TruckManagement item : myTruckManagementList) { + String truck_number = item.getTruck_number(); + Truck myPalletTruck = truckExtendMapper.getPalletTruckForNumber(truck_number); + if (myPalletTruck.getTruck_state() != 4) { + myPalletTruck.setTruck_state(4); + truckMapper.update(myPalletTruck); + } + } + } + //再获取我的车辆信息(含最新更新的被列入黑名单信息) + return truckExtendMapper.getPalletTruckForUsers(users_id); + } + + /** + * 修改或添加我的板车信息 + * + * @param palletTruck 板车数据实体 + * @return 返回执行结果 + */ + @Override + public Integer postMyPalletTruck(Truck palletTruck) { + if (palletTruck == null) { + return 0; + } + //判断板车id是否存在 + String id = palletTruck.getId(); + //检查是否设置为默认车辆 + // Integer truck_state = palletTruck.getTruck_state(); + //如果truck_state=1 +// if (Objects.equals(truck_state, 1)) { +// String users_id = palletTruck.getUsers_id(); +// //重置其他所有车辆的状态为0,除非被列为黑名单(truck_state=4) +// if (users_id != null && !users_id.isEmpty()) { +// int x = truckExtendMapper.setTruckSateToGeneral(users_id); +// } +// } + //将数据更新信息定义为返回值 + Integer x = 0; + if (id != null && id.length() > 0) { + //修改 + //palletTruck.setCreate_time(myPalletTruck.getCreate_time()); + palletTruck.setUpdate_time(FormatDateTime.dateToStr(new Date())); + palletTruck.setIs_del(0); + //允许null值覆盖 + x = truckMapper.updateEX(palletTruck); + + } else { + String user_id = palletTruck.getUsers_id(); + Truck myPalletTruck = (Truck) truckMapper.getTruckByUsersId(user_id); + if (myPalletTruck != null) { + palletTruck.setId(myPalletTruck.getId()); + palletTruck.setCreate_time(FormatDateTime.dateToStr(new Date())); + palletTruck.setUpdate_time(FormatDateTime.dateToStr(new Date())); + palletTruck.setTruck_state(1); + palletTruck.setIs_del(0); + x = truckMapper.updateEX(palletTruck); + } else { + //添加 + palletTruck.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase(Locale.ROOT)); + palletTruck.setCreate_time(FormatDateTime.dateToStr(new Date())); + palletTruck.setUpdate_time(FormatDateTime.dateToStr(new Date())); + palletTruck.setTruck_state(1); + palletTruck.setIs_del(0); + truckMapper.insert(palletTruck); + x = 1; + } + + + } + return x; + } + + /** + * 删除我的板车信息 + * + * @param palletTruck_id 板车id + * @return 返回执行结果 + */ + @Override + public Integer delMyPalletTruck(String palletTruck_id) { + //return truckMapper.logicDel(palletTruck_id); + //王琛建议硬删除 + return truckMapper.delete(palletTruck_id); + } + + /** + * 删除用户所有板车信息 + * + * @param users_id 板车id + * @return 返回执行结果 + */ + @Override + public Integer deleteTruckByUsersId(String users_id) { + //return truckMapper.logicDel(users_id); + //王琛建议硬删除 + return truckMapper.deleteTruckByUsersId(users_id); + } + + /** + * 我的车辆黑名单信息 truck_management + * + * @param users_id 司机id + * @return 返回我的车辆黑名单信息 + */ + @Override + public List getMyTruckManagement(String users_id) { + return truckExtendMapper.getMyTruckManagement(users_id); + } + + /** + * 提交反馈意见 + * + * @param feedback 反馈意见数据实体 + * @return 返回执行结果 + */ + @Override + public Integer postFeedback(Feedback feedback) { + //数据补全 + Date date = new Date(); + feedback.setId(UUID.randomUUID().toString().replace("-", "").toLowerCase()); + feedback.setCreate_time(FormatDateTime.dateToStr(date)); + feedback.setUpdate_time(FormatDateTime.dateToStr(date)); + feedback.setIs_del(0); + //写入到数据库 + String id = feedbackMapper.insert(feedback); + return (id != null && id.length() > 0) ? 1 : 0; + } + + /** + * 我的预约信息列表 + * + * @param users_id 司机id + * @return 返回我的预约信息列表 + */ + @Override + public List getMyAppointmentList(String users_id) { + return appointmentExtendMapper.getMyAppointmentList(users_id); + } + + /** + * 根据预约ids + * + * @param ids 预约ids + * @return 返回预约列表 + */ + @Override + public List getAppointmentByIds(List ids) { + return appointmentMapper.getAppointmentByIds(ids); + } + + /** + * 我的预约信息模糊查询分页列表 + * + * @param users_id 司机id + * @param keywords 查询关键字 + * @param approach_date 进场日期 + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回我的预约信息模糊查询分页列表 + */ + @Override + public PageInfo getMyAppointmentListForPage(String users_id, String keywords, String approach_date, Integer pageNum, Integer pageSize) { + + //初始化PageHelper + pageNum = (pageNum != null) ? pageNum : 1; //当前页码 + pageSize = (pageSize != null) ? pageSize : 10; //每页记录条数 + List mylist = new ArrayList<>(); + //根据预约日期查询 + if (approach_date != null && approach_date.length() == 10) { + LocalDate myApproach_date = LocalDate.parse(approach_date); + //初始化PageHelper + PageHelper.startPage(pageNum, pageSize, true, false, false); + mylist = appointmentExtendMapper.getMyAppointmentListForDate(users_id, myApproach_date); + } + //根据关键字查询 + if (keywords != null && keywords.length() > 0) { + // keywords 船名或航次的关键字 + //获取关键字匹配的 appointment_id 值的列表 + List id_list = appointmentExtendMapper.getAppointmentDetailListForKeyWords(keywords); + //去重 + Set my_id_list = new HashSet<>(id_list); + id_list = new ArrayList<>(my_id_list); + + //初始化PageHelper + PageHelper.startPage(pageNum, pageSize, true, false, false); + //根据idList查询我的预约记录 + mylist = appointmentExtendMapper.getMyAppointmentListForIdList(users_id, id_list); + } + //无条件参数时,查询全部 + if ((keywords == null || keywords.length() == 0) && (approach_date == null || approach_date.length() == 0)) { + //初始化PageHelper + PageHelper.startPage(pageNum, pageSize, true, false, false); + mylist = appointmentExtendMapper.getMyAppointmentList(users_id); + } + //获取分页数据 + return new PageInfo(mylist); + } + + @Override + public PageInfo getMyAppointmentListForPageNew(String users_id, String keywords, String approach_date, Integer pageNum, Integer pageSize) { + //初始化PageHelper + pageNum = (pageNum != null) ? pageNum : 1; //当前页码 + pageSize = (pageSize != null) ? pageSize : 10; + List mylist = new ArrayList<>(); + PageHelper.startPage(pageNum, pageSize, true, false, false); + mylist = appointmentExtendMapper.getAppointmentListForCondition(users_id, keywords, approach_date); + return new PageInfo(mylist); + } + + /** + * 我的预约信息按日期查询分页列表 + * + * @param users_id 司机id + * @param approach_date 预约进场日期 + * @param pageNum 页码 + * @param pageSize 数据条数 + * @return 返回我的预约信息按日期查询分页列表 + */ + @Override + public PageInfo getMyAppointmentListByDateForPage(String users_id, String approach_date, Integer pageNum, Integer pageSize) { + //初始化PageHelper + pageNum = (pageNum != null) ? pageNum : 1; //当前页码 + pageSize = (pageSize != null) ? pageSize : 10; //每页记录条数 + List mylist = new ArrayList<>(); + //根据预约日期查询 + if (approach_date != null && approach_date.length() == 10) { + LocalDate myApproach_date = LocalDate.parse(approach_date); + //初始化PageHelper + PageHelper.startPage(pageNum, pageSize, true, false, false); + mylist = appointmentExtendMapper.getMyAppointmentListForDate(users_id, myApproach_date); + } + //无条件参数时,查询全部 + if ((approach_date == null || approach_date.length() == 0)) { + //初始化PageHelper + PageHelper.startPage(pageNum, pageSize, true, false, false); + mylist = appointmentExtendMapper.getMyAppointmentList(users_id); + } + //获取分页数据 + return new PageInfo(mylist); + } + + /** + * 新手攻略 + * + * @return 返回新手攻略 + */ + @Override + public List getNoviceIntroduction() { + return noviceIntroductionMapper.getList(); + } + + /** + * 获取我的当前预约 + * + * @param users_id 用户id + * @return 返回获取我的当前预约 + */ + @Override + public Appointment getMyAppointment(String users_id) { + return appointmentExtendMapper.getMyAppointment(users_id); + } + + /** + * 根据Id获取用户信息 + * + * @param users_id 用户id + * @return 返回用户信息 + */ + @Override + public Users getUsersById(String users_id) { + return usersMapper.getById(users_id); + } + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/NewsServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/NewsServiceImpl.java new file mode 100644 index 0000000..76fed2f --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/NewsServiceImpl.java @@ -0,0 +1,35 @@ +package com.haitongauto.rtosac.service.impl; +import com.haitongauto.mapper.base.RequesterMapper; +import com.haitongauto.models.pojo.EntryInstruct; +import com.haitongauto.models.pojo.Requester; +import com.haitongauto.rtosac.service.NewsService; +import com.haitongauto.mapper.client.OtherExtendMapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.List; + +@Service +public class NewsServiceImpl implements NewsService { + @Autowired + OtherExtendMapper otherExtendMapper; + + @Autowired + RequesterMapper requesterMapper; + + /** + * 获取发送给指定用户的(最近10条)指令信息 + * @param users_id 用户id + * @return 返回定用户的(最近10条)指令信息 + */ + @Override + public List getEntryInstructionsForUsers(@Param("users_id") String users_id){ + return otherExtendMapper.getEntryInstructionsForUsers(users_id); + } + + @Override + public Requester getRequesterForType(Integer requestType) { + return requesterMapper.getRequesterForType(requestType); + } + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/PunchClockServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/PunchClockServiceImpl.java new file mode 100644 index 0000000..a169f1e --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/PunchClockServiceImpl.java @@ -0,0 +1,294 @@ +package com.haitongauto.rtosac.service.impl; + +import com.bestvike.linq.Linq; +import com.haitongauto.interfaces.PortAreaInterface; +import com.haitongauto.mapper.base.AppointmentMapper; +import com.haitongauto.mapper.base.PunchClockMapper; +import com.haitongauto.mapper.base.PortAreasMapper; +import com.haitongauto.models.pojo.Appointment; +import com.haitongauto.models.pojo.PortArea; +import com.haitongauto.models.pojo.PunchClock; +import com.haitongauto.rtosac.service.PunchClockService; +import com.haitongauto.mapper.client.AppointmentExtendMapper; +import com.haitongauto.mapper.client.PunchClockExtendMapper; +import com.haitongauto.utils.DateTimeHelper; +import com.haitongauto.utils.FormatDateTime; +import com.haitongauto.utils.QueueNumberHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalTime; +import java.util.Date; +import java.util.List; + +@Service +public class PunchClockServiceImpl implements PunchClockService { + @Autowired + PortAreaInterface portAreaInterface; + @Autowired + AppointmentMapper appointmentMapper; + @Autowired + PunchClockMapper punchClockMapper; + @Autowired + PortAreasMapper portAreasMapper; + @Autowired + AppointmentExtendMapper appointmentExtendMapper; + @Autowired + PunchClockExtendMapper punchClockExtendMapper; + + /** + * 检查是否有预约(查询是否存在有预约待签到)的预约数据 + * + * @param users_id 用户id + * @return 返回预约信息 + */ + @Override + public Appointment getIincompleteAppointment(String users_id) { + return appointmentExtendMapper.getActiveAppointment(users_id); + } + + /** + * 签到打卡提交 + * + * @param users_id 用户id + * @param appointment_id 预约id + * @param port_area_id 港区id + * @param punch_poi 坐标 + * @return 返回提交结果 + */ + @Override + public PunchClock postPunchClockStart(String users_id, String appointment_id, String port_area_id, String punch_poi, String punch_address) { + //获取当前日期时间 + Date datetime = new Date(); + //更新预约状态 + Appointment appointment = appointmentMapper.getById(appointment_id); + if (appointment == null) { + return null; + } + + if (appointment.getAppointment_state().equals(2)) { + return null; + } + + //普通预约签到 + if (appointment.getAppointment_type() != null) { + if (appointment.getAppointment_type().equals(1)) { + appointment.setAppointment_state(2); + appointment.setCheck_in_time(FormatDateTime.dateTimeToStr(datetime)); + appointment.setUpdate_time(FormatDateTime.dateToStr(datetime)); + } + //特保区预约签到 + if (appointment.getAppointment_type().equals(2)) { + appointment.setAppointment_state(2); + appointment.setCheck_in_time(FormatDateTime.dateTimeToStr(datetime)); + appointment.setUpdate_time(FormatDateTime.dateToStr(datetime)); + } + } else { + appointment.setAppointment_state(2); + appointment.setCheck_in_time(FormatDateTime.dateTimeToStr(datetime)); + appointment.setUpdate_time(FormatDateTime.dateToStr(datetime)); + } + + Integer x = appointmentMapper.update(appointment); + PunchClock myPunchClock = null; + myPunchClock = punchClockMapper.getPunchClockByAppointmentId(appointment.getId()); + if (x > 0) { + //更改打卡记录 + if (myPunchClock != null) { + //获取当前日期 + Date date = new Date(); + //获取当前日期最后一个排队编号 + String last_queue_number = punchClockExtendMapper.getLastQueueNumber(date, appointment.getPort_area_id()); + //生成新的排队编号 + //排队号需求变更,格式"2308210001" + String queue_number = QueueNumberHelper.getNewQueueNumber(last_queue_number); + //添加打卡信息 + myPunchClock.setUsers_id(users_id); //'用户id' + myPunchClock.setAppointment_id(appointment_id); //'预约Id' + myPunchClock.setQueue_number(queue_number); //排队编号(1000-9999) + myPunchClock.setStart_time(FormatDateTime.dateTimeToStr(datetime)); //'签到打卡日期时间' + myPunchClock.setPort_area_id(port_area_id); //'打卡港区' + myPunchClock.setPunch_address(punch_address); + myPunchClock.setPunch_clock_type(1); //'打卡类别(0-预约未签到,1-签到,2-已进港,3-操作中,4-已完成,5-已离港)' + myPunchClock.setPunch_clock_poi(punch_poi); //'打卡位置(位置坐标)' + myPunchClock.setUpdate_time(FormatDateTime.dateTimeToStr(datetime)); //'更新时间' + myPunchClock.setIs_del(0); //'是否软删除' + //更新到数据库 + Integer res = punchClockMapper.update(myPunchClock); + } + } + return myPunchClock; + } + + /** + * 完成打卡提交 + * + * @param appointment_id 预约id + * @param punch_clock_id 打卡id + * @param over_address 打卡地址 + * @return 返回完成打卡提交执行结果 + */ + @Override + public PunchClock postPunchClockOver(String appointment_id, String punch_clock_id, String over_address) { + //获取当前日期时间 + Date datetime = new Date(); + //更新预约状态 + Appointment appointment = appointmentMapper.getById(appointment_id); + if (appointment != null) { + appointment.setAppointment_state(6); + appointment.setCheck_over_time(FormatDateTime.dateTimeToStr(datetime)); + appointment.setGate_canal_out_time(FormatDateTime.dateTimeToStr(datetime)); + appointment.setUpdate_time(FormatDateTime.dateTimeToStr(datetime)); + Integer x = appointmentMapper.update(appointment); + } + //更新打卡状态为完成状态 + //PunchClock punchClock = punchClockMapper.getById(punch_clock_id); + PunchClock punchClock = punchClockMapper.getPunchClockByAppointmentId(appointment_id); + if (punchClock != null) { + punchClock.setOver_time(FormatDateTime.dateTimeToStr(datetime)); + punchClock.setOver_address(over_address); + punchClock.setPunch_clock_type(4); + punchClock.setUpdate_time(FormatDateTime.dateTimeToStr(datetime)); + punchClockMapper.update(punchClock); + } + return punchClock; + } + + + /** + * 根据预约Id获取获取打卡记录 + * + * @param appointment_id 预约id + * @return 返回打卡记录 + */ + @Override + public PunchClock getPunchClockForAppintementId(String appointment_id) { + return punchClockExtendMapper.getPunchClockForAppintementId(appointment_id); + } + + /** + * 查询指定司机某一天(指定日期)的打卡记录 + * + * @param date 指定日期 + * @param users_id 用户id + * @return 返回打卡记录列表 + */ + @Override + public List getPunchClockForDate(String date, String users_id) { + return punchClockExtendMapper.getPunchClockForDate(date, users_id); + } + + /** + * 查询指定司机某年某月的打卡记录 + * + * @param year 年 + * @param month 月 + * @param users_id 用户id + * @return 返回打卡记录列表 + */ + @Override + public List getPunchClockForYM(Integer year, Integer month, String users_id) { + //获取该用户的所有打卡记录 + if (users_id == null || users_id.isEmpty()) { + return null; + } + List mylist = punchClockExtendMapper.getPunchClockForYM(users_id, year, month); + return mylist; + } + +// @Override +// public List getPunchClockForYM(Integer year, Integer month, String users_id) { +// //获取该用户的所有打卡记录 +// List mylist = punchClockExtendMapper.getPunchClockForYM(users_id); +// if (users_id == null || users_id.isEmpty()) { +// return null; +// } +// //String time="2023-05-06 10:11:12"; +// //LocalDateTime date= DateTimeHelper.DateTimeStrToLocalDateTime(time.replace(" ","T")); +// //int year1=date.getYear(); +// //int month1th=date.getMonthValue(); +// +// //年份、月份过滤 +// //mylist = mylist.stream().filter(a -> LocalDateTime.parse(a.getStart_time()).getYear() == year && LocalDateTime.parse(a.getStart_time()).getMonthValue() == month).collect(Collectors.toList()); +// if (year != null && year != 0 && month != null && month != 0) { +// //mylist = Linq.of(mylist).where(p -> p.getStart_time().contains(year.toString())).toList(); +// mylist = Linq.of(mylist).where(p -> p.getStart_time() != null && DateTimeHelper.DateTimeStrToLocalDateTime(p.getStart_time()).getYear() == year).toList(); +// mylist = Linq.of(mylist).where(p -> p.getStart_time() != null && DateTimeHelper.DateTimeStrToLocalDateTime(p.getStart_time()).getMonthValue() == month).toList(); +// } +// return mylist; +// +// } + + + /** + * 获取港区 + * + * @param port_area_id 港区id + * @return 返回港区信息 + */ + @Override + public PortArea getPortAreaForId(String port_area_id) { + return portAreasMapper.getById(port_area_id); + } + + /** + * 获取港区中心点坐标 + * + * @param port_area_id 港区id + * @return 返回港区中心点坐标 + */ + @Override + public String getPortAreaPoi(String port_area_id) { + PortArea portAreas = (PortArea) portAreasMapper.getById(port_area_id); + //从哪吒接口拿,哪吒接口缺少字段 港区中心点坐标Area_center_poi + if (portAreas == null) { + //哪吒接口 + List portAreaList = portAreaInterface.getPortArea(); + if (portAreaList != null) { + portAreas = Linq.of(portAreaList).firstOrDefault(p -> p.getId().equals(port_area_id)); + } + } + String area_center_poi = ""; + if (portAreas != null) { + area_center_poi = portAreas.getArea_center_poi(); + } + return area_center_poi; + } + + /** + * 获取签到打卡排队序号 + * + * @param appointment_id 预约id + * @return 返回签到打卡排队序号 + */ + @Override + public String getQueueNumber(String appointment_id) { + //根据预约id和签到日期即可获得签到排队顺序号 + return punchClockExtendMapper.getQueueNumberForIdDate(appointment_id); + } + + /** + * 获取当前排队前面还剩多少车辆未进港 + * + * @param approach_date 进场日期 + * @param port_area_id 港区id + * @param queue_number 排队号 + * @return 返回查询结果 + */ + @Override + public Integer getNumberBefore(String approach_date, String port_area_id, String queue_number) { + return punchClockExtendMapper.getNumberBeforeMe(approach_date, port_area_id, queue_number); + } + + @Override + public Integer updatePunchClock(PunchClock punchClock) { + return punchClockMapper.update(punchClock); + } + + @Override + public String getLastQueueNumber(Date data, String port_area_id) { + return punchClockExtendMapper.getLastQueueNumber(data, port_area_id); + } + + +} \ No newline at end of file diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ResponseImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ResponseImpl.java new file mode 100644 index 0000000..9e95e56 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ResponseImpl.java @@ -0,0 +1,119 @@ +package com.haitongauto.rtosac.service.impl; + +import com.alibaba.fastjson.JSON; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.haitongauto.rtosac.service.Response; +import com.haitongauto.models.dto.Responser; +import org.springframework.stereotype.Service; + +@Service +public class ResponseImpl implements Response { + + /** + * 封装为返回Json对象 + * + * @param bl:请求是否成功 + * @param data:返回数据 + * @return 返回Json对象 + */ + @Override + public String getResponseData(Boolean bl, Object data) { + //创建返回数据 + Integer code = (bl) ? 200 : 404; + String message = (bl) ? "request success" : "request fail"; + //添加到返回对象 + Responser responser = new Responser(); + responser.setCode(code); + responser.setMessage(message); + responser.setData(data); + //解析为Json字符串 + //返回 + return JSON.toJSONString(responser); + } + + + /** + * 封装为返回Json对象 + * + * @param bl:请求是否成功 + * @param data:返回数据 + * @return 返回Json对象 + */ + @Override + public String getResponseData(Boolean bl, Object data, String msg) { + //创建返回数据 + Integer code = (bl) ? 200 : 404; + String message; + if (msg != null && !msg.isEmpty()) { + message = msg; + } else { + message = (bl) ? "request success" : "request fail"; + } + //添加到返回对象 + Responser responser = new Responser(); + responser.setCode(code); + responser.setMessage(message); + responser.setData(data); + //解析为Json字符串 + //返回 + return JSON.toJSONString(responser); + } + + + /** + * 封装为返回Json对象(带null) + * @param bl:请求是否成功 + * @param data:返回数据 + * @return 返回Json对象 + */ + @Override + public String getResponseDataJavaJson(Boolean bl,Object data){ + //创建返回数据 + Integer code = (bl) ? 200 : 404; + String message = (bl) ? "request success" : "request fail"; + //添加到返回对象 + Responser responser = new Responser(); + responser.setCode(code); + responser.setMessage(message); + responser.setData(data); + //解析为Json字符串 + // 将对象转换为 JSON 字符串 + ObjectMapper objectMapper = new ObjectMapper(); + //String json = objectMapper.writeValueAsString(data); + String json = null; + try { + json = objectMapper.writeValueAsString(responser); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + //返回 + return json; + } + + @Override + public String getRtosResponseData(Boolean bl, Object data, String errorCode) { + //创建返回数据 + Integer code = (bl) ? 200 : 404; + String message=""; + if (errorCode != null && !errorCode.isEmpty()) { + code = Integer.parseInt(errorCode); + } + if (code.equals(401)){ + message="用户权限过期,请重新登录"; + } + else { + message = (bl) ? "request success" : "request fail"; + } + //添加到返回对象 + Responser responser = new Responser(); + responser.setCode(code); + responser.setMessage(message); + responser.setData(data); + //解析为Json字符串 + //返回 + return JSON.toJSONString(responser); + } + + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/UsersServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/UsersServiceImpl.java new file mode 100644 index 0000000..ed1ed68 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/UsersServiceImpl.java @@ -0,0 +1,38 @@ +package com.haitongauto.rtosac.service.impl; +import com.haitongauto.mapper.base.TruckMapper; +import com.haitongauto.mapper.base.UsersMapper; +import com.haitongauto.models.pojo.Truck; +import com.haitongauto.models.pojo.Users; +import com.haitongauto.rtosac.service.UsersService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +@Service +public class UsersServiceImpl implements UsersService { + @Autowired + UsersMapper usersMapper; + @Autowired + TruckMapper truckMapper; + + @Override + public String insert(Users users) { + return usersMapper.insert(users); + } + @Override + public Integer update(Users users) { + return usersMapper.update(users); + } + @Override + public Truck getTruckByWxOpenID(String wx_openid) { + return truckMapper.getTruckByOpenId(wx_openid); + } + @Override + public Truck getTruckByUserId(String userId) { + return truckMapper.getTruckByUsersId(userId); + } + + @Override + public Users getUsersByUserId(String userId) { + return usersMapper.getById(userId); + } + +} diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/VehicleServiceImpl.java b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/VehicleServiceImpl.java new file mode 100644 index 0000000..1c78866 --- /dev/null +++ b/wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/VehicleServiceImpl.java @@ -0,0 +1,92 @@ +package com.haitongauto.rtosac.service.impl; +import com.haitongauto.models.ido.departure.DepartureDetailIdo_DTO; +import com.haitongauto.models.ido.departure.DepartureVehicleIdo_DTO; +import com.haitongauto.models.ido.receiving.ReceivingDetailIdo_DTO; +import com.haitongauto.models.ido.receiving.ReceivingVehicleIdo_DTO; +import com.haitongauto.rtosac.service.VehicleService; +import com.haitongauto.interfaces.ReceivingVehicleInterface; +import com.haitongauto.interfaces.DepartureVehicleInterface; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class VehicleServiceImpl implements VehicleService { + @Autowired + ReceivingVehicleInterface receivingVehicleInterface; + @Autowired + DepartureVehicleInterface departureVehicleInterface; + + /** + * 获取收车凭证的分页数据 + * + * @param current 当前页码 + * @param size 数据条数(非必填) + * @return 返回收车凭证的分页数据 + */ + @Override + public ReceivingVehicleIdo_DTO getVehicleReceivingList(String printTicketTime, String query, Integer current, Integer size) { + //通过外部接口获取收车分页数据 + return receivingVehicleInterface.getReceivingVehicleList(printTicketTime, query, current, size); + } + + /** + * 获取指定id的待核对收车凭证信息 + * + * @param id 收车凭证id + * @return 返回收车凭证信息 + */ + @Override + public ReceivingDetailIdo_DTO getVehicleReceivingInfo(String id) { + return receivingVehicleInterface.getReceivingDetailForId(id); + } + + /** + * 完成收车核对 + * + * @param id 收车凭证id + * @return 返回核对结果 + */ + @Override + public boolean vehicleReceivingOver(String id) { + //状态更新到数据库 + return receivingVehicleInterface.checkReceivingVehicle(id); + } + + /** + * 获取提车凭证的分页数据 + * + * @param current 当前页码 + * @param size 数据条数(非必填) + * @return 返回提车凭证的分页数据 + */ + @Override + public DepartureVehicleIdo_DTO getVehicleDepartureInfoList(String printTicketTime, String query, Integer current, Integer size) { + return departureVehicleInterface.getDepartureVehicleList(printTicketTime, query, current, size); + } + + + /** + * 获取指定id的提车明细 + * + * @param id 指定明细id + * @return 返回提车明细 + */ + @Override + public DepartureDetailIdo_DTO getVehicleDepartureInfo(String id) { + //提醒:此处不应该使用提车信息类,而应该使用提车明细类 + return departureVehicleInterface.getDepartureDetailForId(id); + } + + /** + * 完成提车核对 + * + * @param id 记录id + * @return 返回核对执行结果 + */ + @Override + public boolean VehicleDepartureOver(String id) { + //获取发车数据 + return departureVehicleInterface.checkDepartureVehicle(id); + } + +} diff --git a/wx-applet/src/main/resources/back/111.yml b/wx-applet/src/main/resources/back/111.yml new file mode 100644 index 0000000..e211fef --- /dev/null +++ b/wx-applet/src/main/resources/back/111.yml @@ -0,0 +1,98 @@ + +# 微信小程序服务配置 +# postgresql数据源配置 +#spring: +# redis: +# database: 0 +# host: 192.168.61.130 +# port: 6379 +# connect-timeout: 1 +# password: Nuzar123456_ +# security: +# oauth2: +# resourceserver: +# opaquetoken: +# client-secret: bossnine +# client-id: trusted-bbw-tally +# introspection-uri: ${auth-server}/saas/token/info +# profiles: +# active: pre +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://localhost:5432/rtos_wx_applet?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: wsnet_906 #Fineidc@2023 #wsnet_906 + +# # 丰网服务器环境:IP:61.184.202.72; port:5432; db:rtos_applet_v2; user: postgres password: Fineidc@2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://61.184.202.72:5432/rtos_applet_v2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: Fineidc@2023 #Fineidc@2023 #wsnet_906 + +# 海通测试环境:IP:192.168.61.114; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://192.168.61.114:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + + +# 开发库本地(公司):IP:192.168.0.16; port:5432; db:rtops_wh; user: rtos_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://192.168.0.16:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + +# 开发库本地:IP:localhost; port:5432; db:rtos_wh; user: postgres password: wsnet906 + +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://localhost:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: wsnet906 + +# # 华为云测试环境:IP:116.205.142.169; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://116.205.142.169:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + +# mybatis配置 +#mybatis: +# mapper-locations: classpath:mappers/*/*.xml +# +## pagehelper 分页插件 +#pagehelper: +# helperDialect: postgresql +# reasonable: true +# supportMethodsArguments: true +# rowBoundsWithCount: true +# params: count=countSql +# +#logging: +# level: +# root: info +# com: +# nuzar: DEBUG +#nuzar: +# cloud: +# jasypt: +# password: RTOS_HTGJ +# security: +# #mode: none +# mode: classic +# saas: +# enabled: true +# #enabled: false +# +# +#mybatis-plus: +# type-enums-package: com.nuzar.rtos.common.enumeration +# +# +## auth-server: http://127.0.0.1:20880 # 认证服务器地址 +#auth-server: https://rtops4.haitongauto.com/auth +##auth-server: http://10.166.1.27:32500/auth/ # 认证服务器地址 \ No newline at end of file diff --git a/wx-applet/src/main/resources/back/bannerX.txt b/wx-applet/src/main/resources/back/bannerX.txt new file mode 100644 index 0000000..737ea48 --- /dev/null +++ b/wx-applet/src/main/resources/back/bannerX.txt @@ -0,0 +1,22 @@ +//////////////////////////////////////////////////////////////////// +// _ooOoo_ // +// o8888888o // +// 88" . "88 // +// (| ^_^ |) // +// O\ = /O // +// ____/`---'\____ // +// .' \\| |// `. // +// / \\||| : |||// \ // +// / _||||| -:- |||||- \ // +// | | \\\ - /// | | // +// | \_| ''\---/'' | | // +// \ .-\__ `-` ___/-. / // +// ___`. .' /--.--\ `. . ___ // +// ."" '< `.___\_<|>_/___.' >'"". // +// | | : `- \`.;`\ _ /`;.`/ - ` : | | // +// \ \ `-. \_ __\ /__ _/ .-` / / // +// ========`-.____`-.___\_____/___.-`____.-'======== // +// `=---=' // +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// 佛祖保佑 永不宕机 永无BUG // +//////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/wx-applet/src/main/resources/back/logback-spring.xml b/wx-applet/src/main/resources/back/logback-spring.xml new file mode 100644 index 0000000..17a4480 --- /dev/null +++ b/wx-applet/src/main/resources/back/logback-spring.xml @@ -0,0 +1,19 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + \ No newline at end of file diff --git a/wx-applet/src/main/resources/back/本地调试.txt b/wx-applet/src/main/resources/back/本地调试.txt new file mode 100644 index 0000000..55003f9 --- /dev/null +++ b/wx-applet/src/main/resources/back/本地调试.txt @@ -0,0 +1,61 @@ +# 微信小程序服务配置 +server: + port: 8891 + +# postgresql数据源配置 +spring: +# profiles: +# active: pre +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://localhost:5432/rtos_wx_applet?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: wsnet_906 #Fineidc@2023 #wsnet_906 + +# # 丰网服务器环境:IP:61.184.202.72; port:5432; db:rtos_applet_v2; user: postgres password: Fineidc@2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://61.184.202.72:5432/rtos_applet_v2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: Fineidc@2023 #Fineidc@2023 #wsnet_906 + +# 海通测试环境:IP:192.168.61.114; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://192.168.61.114:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + username: rtops_wh + password: wh#2023 + + + # 开发库本地(公司):IP:192.168.0.16; port:5432; db:rtops_wh; user: rtos_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://192.168.0.16:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + + # 开发库本地:IP:localhost; port:5432; db:rtos_wh; user: postgres password: wsnet906 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://localhost:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: wsnet906 + +# # 华为云测试环境:IP:116.205.142.169; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://116.205.142.169:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + +# mybatis配置 +mybatis: + mapper-locations: classpath:mappers/*/*.xml + +# pagehelper 分页插件 +pagehelper: + helperDialect: postgresql + reasonable: true + supportMethodsArguments: true + rowBoundsWithCount: true +# params: count=countSql \ No newline at end of file diff --git a/wx-applet/src/main/resources/back/远程.yml b/wx-applet/src/main/resources/back/远程.yml new file mode 100644 index 0000000..3308788 --- /dev/null +++ b/wx-applet/src/main/resources/back/远程.yml @@ -0,0 +1,8 @@ +# 微信小程序服务配置 +server: + port: 8891 + +# postgresql数据源配置 +spring: + profiles: + active: pre diff --git a/wx-applet/src/main/resources/bootstrap-pre.yml b/wx-applet/src/main/resources/bootstrap-pre.yml new file mode 100644 index 0000000..12247d0 --- /dev/null +++ b/wx-applet/src/main/resources/bootstrap-pre.yml @@ -0,0 +1,25 @@ +spring: + cloud: + nacos: + server-addr: 192.168.61.130:8848 + discovery: + enabled: true + server-addr: 192.168.61.130:8848 + namespace: 4f38d093-5ff8-46f0-974f-08453b0980f4 + file-extension: yaml + config: + enabled: true + server-addr: 192.168.61.130:8848 + namespace: 4f38d093-5ff8-46f0-974f-08453b0980f4 + file-extension: yaml + group: DEFAULT_GROUP + prefix: ${spring.application.name} + shared-configs: + - data-id: rtops-pre.yaml + username: nacos + password: Nuzar123456_#QWE +#nuzar: +# cloud: +# security: +# permit-all: /swagger-resources/**,/webjars/**,/swagger-ui.html/*,/swagger-ui.html,/v2/**,/appointment/execTruckOrderNsFin +# - data-id: rtops-st.yaml diff --git a/wx-applet/src/main/resources/bootstrap-prod.yml b/wx-applet/src/main/resources/bootstrap-prod.yml new file mode 100644 index 0000000..d441bf4 --- /dev/null +++ b/wx-applet/src/main/resources/bootstrap-prod.yml @@ -0,0 +1,27 @@ +spring: + cloud: + nacos: + server-addr: nacos1:8848,nacos2:8848,nacos3:8848 + discovery: + enabled: true + server-addr: nacos1:8848,nacos2:8848,nacos3:8848 + namespace: 80f92d8d-5c3e-41bd-a0c0-cb5c63652340 + file-extension: yaml + config: + enabled: true + server-addr: nacos1:8848,nacos2:8848,nacos3:8848 + namespace: 80f92d8d-5c3e-41bd-a0c0-cb5c63652340 + file-extension: yaml + group: DEFAULT_GROUP + prefix: ${spring.application.name} + shared-configs: + - data-id: rtops-prod.yaml + username: nacos + password: Nuzar123456_@HTGJ1 +#nuzar: +# cloud: +# security: +# permit-all: /swagger-resources/**,/webjars/**,/swagger-ui.html/*,/swagger-ui.html,/v2/**,/appointment/execTruckOrderNsFin + + +# - data-id: rtops-st.yaml diff --git a/wx-applet/src/main/resources/bootstrap.yml b/wx-applet/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..8624847 --- /dev/null +++ b/wx-applet/src/main/resources/bootstrap.yml @@ -0,0 +1,70 @@ +# 微信小程序服务配置 +server: + port: 8891 + shutdown: graceful + + +# postgresql数据源配置 +spring: + application: + name: rtos-mini + profiles: + active: pre + +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://localhost:5432/rtos_wx_applet?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: wsnet_906 #Fineidc@2023 #wsnet_906 + +# # 丰网服务器环境:IP:61.184.202.72; port:5432; db:rtos_applet_v2; user: postgres password: Fineidc@2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://61.184.202.72:5432/rtos_applet_v2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: Fineidc@2023 #Fineidc@2023 #wsnet_906 + +# 海通测试环境:IP:192.168.61.114; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://192.168.61.114:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + + +# 开发库本地(公司):IP:192.168.0.16; port:5432; db:rtops_wh; user: rtos_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://192.168.0.16:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + +# # 开发库本地:IP:localhost; port:5432; db:rtos_wh; user: postgres password: wsnet906 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://localhost:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: postgres +# password: wsnet906 + +# 华为云测试环境:IP:116.205.142.169; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 +# datasource: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://116.205.142.169:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 +# username: rtops_wh +# password: wh#2023 + +# mybatis配置 +#mybatis: +#mapper-locations: classpath:mappers/*/*.xml + +# +## pagehelper 分页插件 +#pagehelper: +#helperDialect: postgresql +#reasonable: true +#supportMethodsArguments: true +#rowBoundsWithCount: true + + +#params: count=countSql + diff --git a/wx-applet/src/main/resources/forward.json b/wx-applet/src/main/resources/forward.json new file mode 100644 index 0000000..94cafde --- /dev/null +++ b/wx-applet/src/main/resources/forward.json @@ -0,0 +1,4 @@ +{ + "url": "http://192.168.161.81:8090/rtopswebapi/api/NsOrder/", + "isOpen": true +} \ No newline at end of file diff --git a/wx-applet/src/main/resources/log4j2.xml b/wx-applet/src/main/resources/log4j2.xml new file mode 100644 index 0000000..32c8f6b --- /dev/null +++ b/wx-applet/src/main/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/wx-applet/src/main/resources/static/client_img/20230427b40efe1e-462f-42df-8c3d-a56e4b3c34ce.jpg b/wx-applet/src/main/resources/static/client_img/20230427b40efe1e-462f-42df-8c3d-a56e4b3c34ce.jpg new file mode 100644 index 0000000..527e65a Binary files /dev/null and b/wx-applet/src/main/resources/static/client_img/20230427b40efe1e-462f-42df-8c3d-a56e4b3c34ce.jpg differ diff --git a/wx-applet/src/main/resources/static/client_img/20230508f463bc91-85c6-46df-a1a3-67af8b0d3525.jpg b/wx-applet/src/main/resources/static/client_img/20230508f463bc91-85c6-46df-a1a3-67af8b0d3525.jpg new file mode 100644 index 0000000..527e65a Binary files /dev/null and b/wx-applet/src/main/resources/static/client_img/20230508f463bc91-85c6-46df-a1a3-67af8b0d3525.jpg differ diff --git a/wx-applet/src/main/resources/static/client_img/aaa.txt b/wx-applet/src/main/resources/static/client_img/aaa.txt new file mode 100644 index 0000000..42d8ebe --- /dev/null +++ b/wx-applet/src/main/resources/static/client_img/aaa.txt @@ -0,0 +1 @@ +ok? \ No newline at end of file diff --git a/wx-applet/src/main/resources/本地.yml b/wx-applet/src/main/resources/本地.yml new file mode 100644 index 0000000..9fa40cf --- /dev/null +++ b/wx-applet/src/main/resources/本地.yml @@ -0,0 +1,66 @@ +# 微信小程序服务配置 + server: + port: 8891 + + + # postgresql数据源配置 + spring: + # profiles: + # active: pre + + # datasource: + # driver-class-name: org.postgresql.Driver + # url: jdbc:postgresql://localhost:5432/rtos_wx_applet?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + # username: postgres + # password: wsnet_906 #Fineidc@2023 #wsnet_906 + + # # 丰网服务器环境:IP:61.184.202.72; port:5432; db:rtos_applet_v2; user: postgres password: Fineidc@2023 + # datasource: + # driver-class-name: org.postgresql.Driver + # url: jdbc:postgresql://61.184.202.72:5432/rtos_applet_v2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + # username: postgres + # password: Fineidc@2023 #Fineidc@2023 #wsnet_906 + + # 海通测试环境:IP:192.168.61.114; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://192.168.61.114:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + username: rtops_wh + password: wh#2023 + + + # 开发库本地(公司):IP:192.168.0.16; port:5432; db:rtops_wh; user: rtos_wh password: wh#2023 + # datasource: + # driver-class-name: org.postgresql.Driver + # url: jdbc:postgresql://192.168.0.16:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + # username: rtops_wh + # password: wh#2023 + + # # 开发库本地:IP:localhost; port:5432; db:rtos_wh; user: postgres password: wsnet906 + # datasource: + # driver-class-name: org.postgresql.Driver + # url: jdbc:postgresql://localhost:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + # username: postgres + # password: wsnet906 + + # 华为云测试环境:IP:116.205.142.169; port:5432; db:rtos_wh; user: rtops_wh password: wh#2023 + # datasource: + # driver-class-name: org.postgresql.Driver + # url: jdbc:postgresql://116.205.142.169:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + # username: rtops_wh + # password: wh#2023 + + # mybatis配置 + mybatis: + mapper-locations: classpath:mappers/*/*.xml + + # pagehelper 分页插件 + pagehelper: + helperDialect: postgresql + reasonable: true + supportMethodsArguments: true + rowBoundsWithCount: true + + + #params: count=countSql + diff --git a/wx-applet/src/main/resources/远程.yml b/wx-applet/src/main/resources/远程.yml new file mode 100644 index 0000000..1847320 --- /dev/null +++ b/wx-applet/src/main/resources/远程.yml @@ -0,0 +1,10 @@ +server: + port: 8891 +spring: + profiles: + active: pre + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://192.168.61.114:5432/rtos_wh?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + username: rtops_wh + password: wh#2023 diff --git a/wx-applet/wx-applet.iml b/wx-applet/wx-applet.iml new file mode 100644 index 0000000..8d73b6f --- /dev/null +++ b/wx-applet/wx-applet.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file