|
@@ -13,10 +13,13 @@ import com.jpsoft.bus.modules.bus.service.VehicleInfoService;
|
|
import com.jpsoft.bus.modules.common.utils.OSSUtil;
|
|
import com.jpsoft.bus.modules.common.utils.OSSUtil;
|
|
import com.jpsoft.bus.modules.common.utils.POIUtils;
|
|
import com.jpsoft.bus.modules.common.utils.POIUtils;
|
|
import com.jpsoft.bus.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.bus.modules.common.utils.PojoUtils;
|
|
|
|
+import com.jpsoft.bus.modules.sys.entity.SysLog;
|
|
|
|
+import com.jpsoft.bus.modules.sys.service.SysLogService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
@@ -39,6 +42,7 @@ import java.util.*;
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/bus/vehicleInfo")
|
|
@RequestMapping("/bus/vehicleInfo")
|
|
@Api(description = "vehicleInfo")
|
|
@Api(description = "vehicleInfo")
|
|
|
|
+@Slf4j
|
|
public class VehicleInfoController {
|
|
public class VehicleInfoController {
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@@ -54,6 +58,9 @@ public class VehicleInfoController {
|
|
@Autowired
|
|
@Autowired
|
|
private GpsDataInfoService gpsDataInfoService;
|
|
private GpsDataInfoService gpsDataInfoService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysLogService sysLogService;
|
|
|
|
+
|
|
@ApiOperation(value="创建空记录")
|
|
@ApiOperation(value="创建空记录")
|
|
@GetMapping("create")
|
|
@GetMapping("create")
|
|
public MessageResult<VehicleInfo> create(){
|
|
public MessageResult<VehicleInfo> create(){
|
|
@@ -408,4 +415,62 @@ public class VehicleInfoController {
|
|
|
|
|
|
return messageResult;
|
|
return messageResult;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="车辆信息一键绑定")
|
|
|
|
+ @RequestMapping(value = "bindBus",method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<Map> bindBus(
|
|
|
|
+ @RequestParam(value="logId",defaultValue="") String logId,
|
|
|
|
+ @RequestAttribute String subject)throws Exception{
|
|
|
|
+
|
|
|
|
+ //当前用户ID
|
|
|
|
+ System.out.println(subject);
|
|
|
|
+
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isEmpty(logId)) {
|
|
|
|
+ throw new Exception("未查到日志信息");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysLog sysLog = sysLogService.get(Long.valueOf(logId));
|
|
|
|
+
|
|
|
|
+ if (sysLog == null) {
|
|
|
|
+ throw new Exception("未查到日志信息");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String sysData = sysLog.getData();
|
|
|
|
+ String[] data = sysData.split(",");
|
|
|
|
+ if (data.length > 2) {
|
|
|
|
+ //车牌号
|
|
|
|
+ String carNum = data[0];
|
|
|
|
+ //平板设备编号
|
|
|
|
+ String activationCode = data[1];
|
|
|
|
+ //设备编号
|
|
|
|
+ String deviceNo = data[2];
|
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.findByCarNum(carNum);
|
|
|
|
+ if (vehicleInfo == null) {
|
|
|
|
+ throw new Exception("未查到车辆信息");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ vehicleInfo.setActivationCode(activationCode);
|
|
|
|
+ vehicleInfo.setDeviceNo(deviceNo);
|
|
|
|
+ vehicleInfo.setUpdateBy(subject);
|
|
|
|
+ vehicleInfo.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ vehicleInfoService.update(vehicleInfo);
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setMessage("绑定成功");
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("绑定失败");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ log.error(ex.getMessage());
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
}
|
|
}
|