Commit 07602a7b authored by kang.nie@inzymeits.com's avatar kang.nie@inzymeits.com
Browse files

提交代码

parent e0c7be76
package com.ssi.config;
import com.google.common.collect.Sets;
import com.ssi.model.RedisDataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
import redis.clients.util.Pool;
import java.util.Objects;
/**
* Redis配置
*/
@Configuration
public class RedisConfig {
protected Logger logger = LoggerFactory.getLogger(RedisConfig.class);
@Autowired
private JetCacheRedisConfig jetCacheRedisConfig;
@Bean
@ConditionalOnProperty(prefix = "redis.node", name = "mode", havingValue = "sentinel")
public Pool sentinelPoolFactory() throws Exception {
logger.info(String.format("redis配置: %s", jetCacheRedisConfig));
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(jetCacheRedisConfig.getPool().getMaxIdle());
jedisPoolConfig.setMaxWaitMillis(jetCacheRedisConfig.getPool().getMaxWait().toMillis());
jedisPoolConfig.setJmxEnabled(true);
JedisSentinelPool jedisPool = new JedisSentinelPool(
jetCacheRedisConfig.getSentinel().getMaster(),
Sets.newHashSet(jetCacheRedisConfig.getSentinel().getNodes()),
jedisPoolConfig,
Integer.parseInt(String.valueOf(jetCacheRedisConfig.getTimeout().toMillis())),
jetCacheRedisConfig.getPassword(),
jetCacheRedisConfig.getDatabase());
return jedisPool;
}
@Bean
@ConditionalOnProperty(prefix = "redis.node", name = "mode", havingValue = "single")
public JedisPool singleNodePoolFactory() throws Exception {
logger.info(String.format("redis配置: %s", jetCacheRedisConfig));
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(jetCacheRedisConfig.getPool().getMaxIdle());
jedisPoolConfig.setMaxWaitMillis(jetCacheRedisConfig.getPool().getMaxWait().toMillis());
jedisPoolConfig.setJmxEnabled(true);
// JedisPool jedisPool = new JedisPool(jedisPoolConfig, new URI(jetCacheRedisConfig.getUrl()), Protocol.DEFAULT_TIMEOUT);
JedisPool jedisPool = new JedisPool(jedisPoolConfig, jetCacheRedisConfig.getHost(), jetCacheRedisConfig.getPort(),
(int)jetCacheRedisConfig.getTimeout().toMillis(),jetCacheRedisConfig.getPassword(),jetCacheRedisConfig.getDatabase(),null);
return jedisPool;
}
@Autowired
private RedisConnectionFactory redisConnectionFactory;
@Bean
public RedisMessageListenerContainer redisMessageListenerContainer() {
RedisMessageListenerContainer redisMessageListenerContainer = new RedisMessageListenerContainer();
redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory);
return redisMessageListenerContainer;
}
@Bean("singleNodePool")
public Pool singleNodePool() {
logger.info(String.format("redis配置: %s", jetCacheRedisConfig));
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(jetCacheRedisConfig.getPool().getMaxIdle());
jedisPoolConfig.setMaxWaitMillis(jetCacheRedisConfig.getPool().getMaxWait().toMillis());
jedisPoolConfig.setJmxEnabled(true);
jedisPoolConfig.setMaxTotal(jetCacheRedisConfig.getPool().getMaxActive());
JedisPool jedisPool = new JedisPool(jedisPoolConfig, jetCacheRedisConfig.getSingleNode().getHost(), jetCacheRedisConfig.getSingleNode().getPort(),
(int)jetCacheRedisConfig.getTimeout().toMillis(),jetCacheRedisConfig.getSingleNode().getPassword(),jetCacheRedisConfig.getSingleNode().getDatabase(),null);
return jedisPool;
}
@Bean
@ConditionalOnProperty(prefix = "redis.node", name = "mode", havingValue = "sentinel")
public RedisDataModel redisDataModel(Pool sentinelPoolFactory){
return new RedisDataModel(sentinelPoolFactory);
}
/***
*
* @param singleNodePoolFactory
* @return
*/
@Bean
@ConditionalOnProperty(prefix = "redis.node", name = "mode", havingValue = "single")
public RedisDataModel redisDataModel(JedisPool singleNodePoolFactory){
return new RedisDataModel(singleNodePoolFactory);
}
@Bean("singleNodeModel")
public RedisDataModel singleNodeModel(Pool singleNodePool){
return new RedisDataModel(singleNodePool);
}
}
\ No newline at end of file
package com.ssi.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import java.util.concurrent.ExecutorService;
/**
* 任务调度配置
* 默认的线城池为SingleThreadScheduledExecutor,所以为单线程
*/
@Configuration
public class ScheduleConfig implements SchedulingConfigurer {
@Value("${spring.schedule.tasks:12}")
private int tasks;
@Autowired
private ExecutorService executorService;
/**
* 配置多线程任务调度
* @param scheduledTaskRegistrar
*/
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.setScheduler(executorService);
}
}
package com.ssi.config;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.google.common.base.Function;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;
/**
* Swagger API配置
* @author xiaofan
* @email ssi-zhangxf@dfmc.com.cn
* @date 2020-01-22 09:22:23
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
// 定义分隔符
private static final String splitor = ";";
@Bean
public Docket createRestApi() {
ParameterBuilder ticketPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<Parameter>();
ticketPar.name("Authorization").description("认证token")
.modelRef(new ModelRef("string")).parameterType("header")
.required(false).build(); //header中的ticket参数非必填,传空也可以
pars.add(ticketPar.build()); //根据每个方法名也知道当前方法在设置什么参数
return new Docket(DocumentationType.SWAGGER_2).apiInfo(this.apiInfo()).groupName("SSI")
.useDefaultResponseMessages(false).enableUrlTemplating(false).select()
.apis(basePackage("com.ssi.controller")).paths(PathSelectors.any())
.build()
.globalOperationParameters(pars);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("Spring Boot Swagger2").description("SSI-API")
.termsOfServiceUrl("http://127.0.0.1:8087/").version("0.0.1").build();
}
public static Predicate<RequestHandler> basePackage(final String basePackage) {
return input -> declaringClass(input).transform(handlerPackage(basePackage)).or(true);
}
private static Function<Class<?>, Boolean> handlerPackage(final String basePackage) {
return input -> {
// 循环判断匹配
for (String strPackage : basePackage.split(splitor)) {
boolean isMatch = input.getPackage().getName().startsWith(strPackage);
if (isMatch) {
return true;
}
}
return false;
};
}
private static Optional<? extends Class<?>> declaringClass(RequestHandler input) {
return Optional.fromNullable(input.declaringClass());
}
}
package com.ssi.constant;
import lombok.Getter;
/**
* redis key 前缀常量
*
* @author 成东
* @since 2020-03-20 9:44
*/
public enum RedisKey {
CRANE_LOCATION("harbor:crane:location:"),
CRANE_INFO("harbor:crane:info:"),
ERROR_V2X_INFO("ivccs:vms:v2x:event:"),
ERROR_TOS_INFO("ivccs:vms:tos:event:"),
EMERGENCY_PARKING("harbor:remote:emergency_parking:"),
VMS_TOS_ORDER("harbor:command:status:"),
VEHICLE_TO_CRANE("harbor:crane:bridge_no:"),
DYNAMIC_FENCE_SWITCH("ivccs:vms:dynamic:fence:switch"),
DYNAMIC_FENCE_ALERT ("DYNAMIC_FENCE_ALERT"),
DYNAMIC_FENCE_ORDER_ERROR ("DYNAMIC_FENCE_ORDER_ERROR"),
VMS_CHARGING_ACTION("VMS_CHARGING_ACTION")
;
public static String getPortMachineryLocation(String no) {
return CRANE_LOCATION.getKeyPrefix() + no;
}
@Getter
private String keyPrefix;
RedisKey(String keyPrefix) {
this.keyPrefix = keyPrefix;
}
}
package com.ssi.constant;
public interface TrafficLightStatus {
Integer LAMP_EXTINCT_11 = 11;//熄灭
Integer LAMP_RED_21 = 21;//红灯
Integer LAMP_YELLOW_22 = 22;//黄灯
Integer LAMP_GREEN_23 = 23;//绿灯
Integer LAMP_WARN_31 = 31;//红黄
}
package com.ssi.constant;
/**
* URL常量类
* @author ZhangLiYao
* @version 1.0
* @date 2020/5/27 9:06
*/
public interface URL {
String TELECONTROL_URL = "/remote/app/control";
String SWITCHAUTO_URL = "/remote/app/switch";
// String TELECONTROL_URL = "/ivccs_vmm/telecontrol/testResult";
String ROAD_DEVICE_CHECKONLINE = "checkonline?rtsp=";
String RTMP_CHECKONLINE = "/checkrtmp?rtmp=";
String ROAD_DEVICE_RTSPSTART = "rtspstart?rtsp=";
String RTMP_PLAY = "/playrtmp?rtmp=";
String ROAD_DEVICE_RTSPSTOP = "rtspstop?rtsp=";
String MAP_QUERY_URL = "/vehicleBuffer/query";
String MAP_Delete_URL = "/vehicleBuffer/delete";
String MAP_UPDATE_STATE_URL = "/vehicleBuffer/state";
String MAP_EDIT_URL="/vehicleBuffer/edit";
String MAP_EDIT_LOCK_URL="/vehicleBuffer/editLock";
String MAP_ADD_URL = "/vehicleBuffer/add";
String MAP_priority_URL = "/vehicleBuffer/priority";
String FENCE_ADD_URL = "/vehicleBuffer/fence/add";
String FENCE_DELETE_URL = "/vehicleBuffer/fence/delete";
String FENCE_UPDATE_URL = "/vehicleBuffer/fence/update";
String FENCE_QUERY_URL = "/vehicleBuffer/fence/list";
String To_ODBU_URL="/api/vms/vehicle/order/task";
String To_ODBU_Cancle="/api/vms/vehicle/order/cancelTask";
String To_ODBU_EDIT_POSITION="/api/vms/update/position";
String To_ODBU_EDIT_STATUS="/api/vms/update/command";
String To_ODBU_RECOVERY_TASK="/api/vms/vehicle/order/recoveryTask";
String To_ODBU_CANCEL_TASK="/api/vms/vehicle/order/cancelTask";
String To_ODBU_TRIGGER = "/command/sendF009";
String To_ODBU_CHANGE_ROAD = "api/vms/vehicle/order/changeRoadTask";
String To_CPS_TASK_STOP = "/cps/command/endCurrentTaskForCPS";
String To_CPS_TASK_RECOVERY = "/cps/command/recoveryCPS";
String upshift_URL="/command/forceGoShipCraneLane";
String EMERGENCY_COMMAND="/remote/app/emergency";
String TRAFFIC_LIGHT="/set/CrossDevControl";
}
package com.ssi.constant;
import java.util.ArrayList;
import java.util.List;
import static java.util.Arrays.asList;
/**
* 一些常量
*/
public class VehicleConstant {
public static final String LOGIN_USER_KEY = "loginUser";
public static final String DEBUG_APP_KEY = "debug_app_key";
public static final String DEBUG_APP_DISTANCE = "debug_app_distance";
public static final String ADMIN_DATABASE_NAME = "ivccs_admin";
public static final int OBU_RECEIVED = 43;//OBU接受
public static final int ADCU_RECEIVED = 66;//ADCU接受
public static final int PATH_PLANNING = 64;//路径规划
public static final int START_TASK = 65;//开始行驶
public static final int FINISH_CHARGING = 35;//完成充电
public static final int FINISH_PACKING = 36;//完成停车(固定停车区任务)
public static final int FINISH_CONFIRM = 37;//三重确认完成
public static final int TASK_CANCEL_SUCCESS = 51;//取消任务成功
public static final int FORCE_CANCEL_SUCCESS = 53;//强制取消任务成功
public static final int TASK_FAIL = 41;//任务终止
//状态模板
public static final List<Integer> statusTemp = new ArrayList<>(asList(42,43,65,49));
public static final int TELE_CONTROL_TYPE_TAKE_OVER = 1;//APP接管
public static final int TELE_CONTROL_TYPE_OPER = 2;//APP操作
public static final int ORDER_EXPIRATION_TIME = 60 * 60 * 1000;
public static final int DEFAULT_EXPIRATION_TIME = 60 * 60 * 24;
public static final int VIDEO_STATUS_ON = 1;
public static final int VIDEO_STATUS_OFF = 0;
public static final int VEHICLE_STATUS_ONLINE = 1;
public static final String START_PUSHER = "startPusher";
public static final String STOP_PUSHER = "stopPusher";
}
package com.ssi.constant.enums;
import lombok.Getter;
/**
* 终端指令执行结果枚举
*/
public enum CommandResultEnum {
SUCCESS(1, "成功"),
FAIL(2, "失败"),
WRONG_COMMAND(3, "指令错误"),
NOT_SUPPORTED(4, "不支持");
@Getter
private int code;
@Getter
private String description;
CommandResultEnum(int code, String description) {
this.code = code;
this.description = description;
}
public static boolean isExecuteSuccess(int code){
if(code == SUCCESS.code){
return true;
}
return false;
}
public static CommandResultEnum find(int code){
CommandResultEnum[] values = CommandResultEnum.values();
for (CommandResultEnum anEnum : values){
if(anEnum.getCode() == code){
return anEnum;
}
}
return null;
}
}
package com.ssi.constant.enums;
import lombok.Getter;
/**
* 指令类型枚举类
*/
public enum CommandTypeEnum {
START_ENGINE(1, "启动"),
STOP_ENGINE(2, "熄火"),
PARK(3, "停车"),
FORWARD(4, "前移"),
BACKWARD(5, "后退"),
LEFT_TURN(6, "左转"),
RIGHT_TURN(7, "右转");
@Getter
private int code;
@Getter
private String description;
CommandTypeEnum(int code, String description) {
this.code = code;
this.description = description;
}
public static CommandTypeEnum find(int code){
CommandTypeEnum[] values = CommandTypeEnum.values();
for (CommandTypeEnum anEnum : values){
if(anEnum.getCode() == code){
return anEnum;
}
}
return null;
}
}
package com.ssi.constant.enums;
/**
* @author SunnyHotz
* @PackageName:com.ssi.enums
* @ClassName:ElecLevelEnum
* @Description:
* @date 2022/8/25 14:40
*/
public enum ElecLevelEnum {
LEVEL_E1(20),
LEVEL_E2(50),
;
private Integer value;
ElecLevelEnum(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
}
package com.ssi.constant.enums;
import lombok.Getter;
/**
* 事件类型枚举类
* @author ZhangLiYao
* @version 1.0
* @date 2020/3/11 15:19
*/
public enum EventTypeEnums {
TEST1("1", "禁止通行"),
TEST2("2", "道路施工"),
TEST3("3", "车车事故");
@Getter
private String code;
@Getter
private String descript;
EventTypeEnums(String code, String descript) {
this.code = code;
this.descript = descript;
}
}
package com.ssi.constant.enums;
import lombok.Getter;
import org.apache.http.HttpStatus;
/**
* 响应状态枚举类
*/
public enum Status {
SUCCESS(1, "成功"),//交易/请求成功
ERROR(-1, "失败"),//交易/请求失败,未知错误
UNAUTHORIZED(HttpStatus.SC_UNAUTHORIZED, "用户资源未授权无法访问"),
NOTFOUND(HttpStatus.SC_NOT_FOUND, "路径不存在,请检查路径是否正确"),
FILEUPLOADERROR(500, "文件上传失败");
@Getter
private int code;
@Getter
private String descript;
Status(int code, String descript) {
this.code = code;
this.descript = descript;
}
}
package com.ssi.constant.enums;
import lombok.Getter;
/**
* 任务地点类型枚举类
*/
public enum TaskLocationTypeEnum {
TO_YARD(1, "去堆场"),
TO_PARK(2, "去停车点"),
TO_FIXED_PARK(3, "去固定停车区"),
TO_TEMPORARY_PARK(4, "去零时停车区"),
TO_PORT(5, "去桥吊"),
TO_CHARGE(6, "充电");
@Getter
private int code;
@Getter
private String description;
TaskLocationTypeEnum(int code, String description) {
this.code = code;
this.description = description;
}
public static TaskLocationTypeEnum find(int code){
TaskLocationTypeEnum[] values = TaskLocationTypeEnum.values();
for (TaskLocationTypeEnum anEnum : values){
if(anEnum.getCode() == code){
return anEnum;
}
}
return null;
}
}
package com.ssi.constant.enums;
import lombok.Getter;
/**
* 任务类型枚举类
*/
public enum TaskTypeEnum {
LOAD(1, "装箱"),
UNLOAD(2, "卸箱"),
CHARGE(3, "充电"),
LOCK(4, "上扭锁"),
UNLOCK(5, "解扭锁"),
PARK(6, "停车"),
TURN_AROUND(7, "掉头");
@Getter
private int code;
@Getter
private String description;
TaskTypeEnum(int code, String description) {
this.code = code;
this.description = description;
}
public static TaskTypeEnum find(int code){
TaskTypeEnum[] values = TaskTypeEnum.values();
for (TaskTypeEnum anEnum : values){
if(anEnum.getCode() == code){
return anEnum;
}
}
return null;
}
}
package com.ssi.constant.enums;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public enum TrafficLightEnum {
LAMP_01(1,"turnRight","北向"),
LAMP_05(5,"straight","北向"),
LAMP_15(15,"turnLeft","北向"),
LAMP_03(3,"turnRight","南向"),
LAMP_13(13,"straight","南向"),
LAMP_17(17,"turnLeft","南向"),
LAMP_04(4,"turnRight","东向"),
LAMP_14(14,"straight","东向"),
LAMP_18(18,"turnLeft","东向"),
LAMP_02(2,"turnRight","西向"),
LAMP_06(6,"straight","西向"),
LAMP_16(16,"turnLeft","西向"),
;
private Integer phaseNo;
private String directName;
private String flagName;
TrafficLightEnum(Integer phaseNo,String directName,String flagName){
this.phaseNo = phaseNo;
this.directName = directName;
this.flagName =flagName;
}
public Integer getPhaseNo() {
return phaseNo;
}
public String getDirectName() {
return directName;
}
public String getFlagName() {
return flagName;
}
public static TrafficLightEnum getEnumByPhaseNo(Integer phaseNo){
TrafficLightEnum trafficLightEnum = Arrays.stream(TrafficLightEnum.values()).filter(e -> e.getPhaseNo().equals(phaseNo)).findAny().orElse(null);
return trafficLightEnum;
}
public static List<TrafficLightEnum> getEnumsByPhaseNoFlagName(String flagName){
List<TrafficLightEnum> enums = Arrays.stream(TrafficLightEnum.values()).filter(e -> e.getFlagName().equals(flagName)).collect(Collectors.toList());
return enums;
}
}
package com.ssi.constant.enums;
import lombok.Getter;
/**
* @author acer
*/
public enum V2xEventTypeEnums {
TYPE_0707(707, "道路拥堵预警"),
TYPE_0904(904, "车辆逆行"),
TYPE_1101(1101, "岸桥拥堵预警"),
TYPE_1102(1102, "港机过河"),
TYPE_1103(1103, "交叉口障碍物预警")
;
@Getter
private Integer code;
@Getter
private String descript;
V2xEventTypeEnums(Integer code, String descript) {
this.code = code;
this.descript = descript;
}
public static V2xEventTypeEnums find(int code){
V2xEventTypeEnums[] values = V2xEventTypeEnums.values();
for (V2xEventTypeEnums anEnum : values){
if(anEnum.getCode() == code){
return anEnum;
}
}
return null;
}
}
package com.ssi.constant.enums;
import lombok.Getter;
/**
* 车辆任务标签枚举类
*/
public enum VehicleTaskLabelEnum {
//FREE(0,"空闲"),
LOAD(1, "装船"),
UNLOAD(2, "卸船"),
ARRANGE_GOODS(3, "理货"),
PARK(4, "停车、空闲"),
CHARGE(5, "充电"),
TEMPORARY_PARK(6, "临时停车"),;
@Getter
private int code;
@Getter
private String description;
VehicleTaskLabelEnum(int code, String description) {
this.code = code;
this.description = description;
}
}
package com.ssi.constant.enums;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
/**
* TOS任务状态枚举类
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum VmsTosOrderStatusEnum {
ARRIVED_PASSPOINT1(1, "到达途径点1"),
ARRIVED_PASSPOINT2(2, "到达途径点2"),
ARRIVED_DESTINATION(3, "到达目的地"),
START_PRECISE_POSITION(16, "开始精准定位"),
START_LOADING(17, "开始装箱"),
START_UNLOADING(18, "开始卸箱"),
START_CHARGING(19, "开始充电"),
FINISH_LOADING(33, "完成装箱"),
FINISH_UNLOADING(34, "完成卸箱"),
FINISH_CHARGING(35, "完成充电"),
FINISH_PARKING(36, "完成停车(固定停车区任务)"),
FINISH_CONFIRM(37, "三重确认完成"),
FINISH_DRIVER_CONFIRM(38, "港机司机确认"),
FINISH_CRANE_CONFIRM(39, "吊具确认"),
TASK_FAIL(41, "任务终止"),
VMS_RECEIVED(42, "平台接受"),
OBU_RECEIVED(43, "OBU接受"),
VEHICLE_LOCKUP(49, "车辆停稳锁死"),
VEHICLE_UNLOCK(50, "车辆解除锁死"),
PATH_PLANNING(64,"路径规划"),
START_TASK(65,"开始行驶"),
// ADCU_RECEIVED(66,"ADCU接受"),
ADCU_RECEIVED_OVERTIME(67,"ADCU接受超时"),
TASK_CANCEL_SUCCESS(51,"取消任务成功"),
TASK_CANCEL_FAIL(52,"取消任务失败"),
FORCE_CANCEL_SUCCESS(53,"强制取消任务成功"),
FORCE_CANCEL_FAIL(54,"强制取消任务失败"),
WAIT_FRONT_CONTAINER(69,"等待双箱前箱指令"),
WAIT_BACK_CONTAINER(70,"等待双箱后箱箱指令"),
SEND_FRONT_CONTAINER(71,"双箱前箱指令发送中"),
SEND_TASK(72,"指令发送中");
@Getter
private int code;
@Getter
private String description;
VmsTosOrderStatusEnum(int code, String description) {
this.code = code;
this.description = description;
}
public static boolean isLoadUnloadStatus(int status){
if(VEHICLE_LOCKUP.code == status || START_LOADING.code == status || START_UNLOADING.code == status
|| FINISH_LOADING.code == status || FINISH_UNLOADING.code == status){
return true;
}
return false;
}
public static VmsTosOrderStatusEnum find(int code){
VmsTosOrderStatusEnum[] values = VmsTosOrderStatusEnum.values();
for (VmsTosOrderStatusEnum anEnum : values){
if(anEnum.getCode() == code){
return anEnum;
}
}
return null;
}
}
package com.ssi.controller;
import com.dfssi.dataplatform.service.annotation.LogAudit;
import com.ssi.response.SSIResponse;
import com.ssi.service.BigScreenService;
import com.ssi.service.VmsVehicleService;
import com.ssi.service.VmsHangerStatusInfoService;
import com.ssi.service.VmsTosOrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Date;
/**
* 大屏相关接口控制器
*/
@Api(tags = "大屏接口控制器",description = "大屏接口")
@RestController
@RequestMapping("/bigScreen")
public class BigScreenController {
@Autowired
private VmsTosOrdersService vmsTosOrdersService;
@Autowired
private VmsVehicleService vmsVehicleService;
@Autowired
private BigScreenService bigScreenService;
@Autowired
private VmsHangerStatusInfoService vmsHangerStatusInfoService;
/**
* 获得各业务箱数
*/
@LogAudit(logName = "获得各业务箱数")
@ApiOperation(value = "获得各业务箱数", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@GetMapping("/queryContainerNumOneDay")
public SSIResponse queryContainerNumByDay(Date queryDate){
if(queryDate == null){
return vmsTosOrdersService.queryContainerNum();
}else {
LocalDateTime startTime = LocalDateTime.of(queryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalTime.MIN);
LocalDateTime endTime = LocalDateTime.of(queryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalTime.MAX);
return vmsTosOrdersService.queryContainerNumOneDay(startTime,endTime);
}
}
/**
* 获得最近n天各业务箱数
*/
@LogAudit(logName = "获得最近n天各业务箱数,不传参数则默认查最近七天")
@ApiOperation(value = "获得最近n天各业务箱数,不传参数则默认查最近七天", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@GetMapping("/queryContainerNumByDay")
public SSIResponse queryContainerNumByDay(Date queryStartDate,Date queryEndDate) throws Exception{
LocalDateTime startTime = null;
LocalDateTime endTime = null;
if(queryStartDate == null && queryEndDate == null){
startTime = LocalDateTime.of(LocalDateTime.now().minus(7, ChronoUnit.DAYS).toLocalDate(), LocalTime.MIN);
endTime = LocalDateTime.of(LocalDateTime.now().minus(1, ChronoUnit.DAYS).toLocalDate(), LocalTime.MAX);
}
if(queryStartDate != null){
startTime = LocalDateTime.of(queryStartDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalTime.MIN);
}
if(queryEndDate != null){
endTime = LocalDateTime.of(queryEndDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalTime.MAX);
}
return vmsTosOrdersService.queryContainerNumByDay(startTime, endTime);
}
/**
* 获得各业务运输效率
*/
@LogAudit(logName = "获得各业务运输效率")
@ApiOperation(value = "获得各业务运输效率", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@GetMapping("/queryContainerAvgTimeOneDay")
public SSIResponse queryContainerAvgTimeOneDay(Date queryDate){
if(queryDate == null){
return vmsTosOrdersService.queryContainerAvgTime();
}else {
LocalDateTime startTime = LocalDateTime.of(queryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalTime.MIN);
LocalDateTime endTime = LocalDateTime.of(queryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalTime.MAX);
return vmsTosOrdersService.queryContainerAvgTimeOneDay(startTime,endTime);
}
}
/**
* 运力分析
*/
@LogAudit(logName = "运力分析")
@ApiOperation(value = "运力分析", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@GetMapping("/transportCapacity")
public SSIResponse transportCapacity(){
return vmsVehicleService.transportCapacity();
}
/**
* 大屏获取运营数据
*/
@LogAudit(logName = "大屏获取运营数据")
@ApiOperation(value = "大屏获取运营数据", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@GetMapping("/getOperateData")
public SSIResponse getOperateData(String vin) throws IOException {
return bigScreenService.getOperateData(Arrays.asList(vin),null,null);
}
/**
* 车辆状态分布
*/
@LogAudit(logName = "车辆状态分布")
@ApiOperation(value = "车辆状态分布", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@GetMapping("/getVehicleStatusDist")
public SSIResponse getVehicleStatusDist(){
return bigScreenService.getVehicleStatusDist();
}
/**
* 大屏查询单车信息
*/
@LogAudit(logName = "大屏查询单车信息")
@GetMapping("/getVehicleInfo")
@ApiOperation(value = "大屏查询单车信息", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public SSIResponse getVehicleInfo(@RequestParam String vin) {
return bigScreenService.getVehicleInfo(vin);
}
/**
* 查询车辆装卸箱时吊具状态信息
*/
@LogAudit(logName = "查询车辆装卸箱时吊具状态信息")
@GetMapping("/getHangerStatusByVin")
@ApiOperation(value = "查询车辆装卸箱时吊具状态信息", response = SSIResponse.class, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public SSIResponse getHangerStatusByVin(@RequestParam String vin) {
return vmsHangerStatusInfoService.getHangerStatusByVin(vin);
}
}
package com.ssi.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dfssi.dataplatform.service.annotation.LogAudit;
import com.ssi.entity.vo.CargoShipConfigDto;
import com.ssi.response.SSIResponse;
import com.ssi.service.CargoShipConfigInfoService;
import io.swagger.annotations.Api;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.shiro.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author SunnyHotz
* @PackageName:com.ssi.controller
* @ClassName:CargoShipConfigController
* @Description:
* @date 2022/10/19 09:59
*/
@Api
@RestController
@RequestMapping("/cargoShipConfig")
public class CargoShipConfigController {
@Autowired
private CargoShipConfigInfoService cargoShipConfigInfoService;
@GetMapping("/onWorkingList")
@LogAudit
public SSIResponse<List<CargoShipConfigDto>> queryOnWorkingList(){
List<CargoShipConfigDto> results = cargoShipConfigInfoService.queryOnWorkingList();
return SSIResponse.ok(results);
}
@LogAudit
@PostMapping("/save")
public SSIResponse<Void> save(@RequestBody JSONObject obj){
JSONArray cargoShipConfigs = obj.getJSONArray("cargoShipConfigs");
if(CollectionUtils.isEmpty(cargoShipConfigs)){
return SSIResponse.ok();
}
List<CargoShipConfigDto> cargoShipConfigDto = cargoShipConfigs.toJavaList(CargoShipConfigDto.class);
cargoShipConfigInfoService.enableConfig(cargoShipConfigDto);
return SSIResponse.ok();
}
@LogAudit
@PostMapping("/update")
public SSIResponse<Void> update(@RequestBody CargoShipConfigDto cargoShipConfigDto){
cargoShipConfigInfoService.updateById(cargoShipConfigDto);
return SSIResponse.ok();
}
@LogAudit
@PostMapping("/listByCondition")
public SSIResponse<JSONObject> listByCondition(@RequestBody CargoShipConfigDto cargoShipConfigDto){
JSONObject results = cargoShipConfigInfoService.listByCondition(cargoShipConfigDto);
return SSIResponse.ok(results);
}
@LogAudit
@GetMapping("/qryEnableCacheArea")
public SSIResponse<List<JSONObject>> qryEnableCacheArea(@RequestParam("beginLocation") String beginLocation,@RequestParam("endLocation") String endLocation){
Assert.notNull(beginLocation,"坐标输入为空");
List<JSONObject> data = cargoShipConfigInfoService.qryEnableCacheArea(beginLocation, endLocation);
return SSIResponse.ok(data);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment