Commit a713ad1b by 刘宇峰

Merge remote-tracking branch 'origin/master'

2 parents 3a625d09 77c2d54e
...@@ -48,4 +48,23 @@ public final class ConstantsDevice { ...@@ -48,4 +48,23 @@ public final class ConstantsDevice {
*/ */
public static final int SOURCE_NO = 0; public static final int SOURCE_NO = 0;
/**
* 试驾设备类型 0:非试驾设备
*/
public static final int NOT_TRIAL_DEVICE_STATUS = 0;
/**
* 试驾设备类型 1:试驾设备
*/
public static final int TRIAL_DEVICE_STATUS = 1;
/**
* 删除标记 0=正常 -1=删除
*/
public static final int NOT_DEL_FLAG = 0;
/**
* 删除标记 1=删除
*/
public static final int DEL_FLAG = 1;
} }
...@@ -28,4 +28,10 @@ public class VehicleDevice extends BaseEntity { ...@@ -28,4 +28,10 @@ public class VehicleDevice extends BaseEntity {
*/ */
@Column(name = "bind_status") @Column(name = "bind_status")
private Integer bindStatus; private Integer bindStatus;
/**
* 试驾类型 0:非试驾设备, 1,试驾设备
*/
@Column(name = "trial_type")
private Integer trialType;
} }
\ No newline at end of file \ No newline at end of file
...@@ -26,4 +26,9 @@ public class TestVehicleVo { ...@@ -26,4 +26,9 @@ public class TestVehicleVo {
* 车架号 * 车架号
*/ */
private String vin; private String vin;
/**
* 1有源 0无源
*/
private Integer source;
} }
...@@ -20,49 +20,26 @@ public class VehicleInfoVo implements Serializable { ...@@ -20,49 +20,26 @@ public class VehicleInfoVo implements Serializable {
private String sn; private String sn;
/** /**
* 主设备型号 1有线 0无线
*/
private Integer deviceType;
/**
* 从设备1 * 从设备1
*/ */
private String sn1; private String sn1;
/** /**
* 从设备型号1 1有线 0无线
*/
private Integer deviceType1;
/**
* 从设备2 * 从设备2
*/ */
private String sn2; private String sn2;
/** /**
* 从设备型号2 1有线 0无线
*/
private Integer deviceType2;
/**
* 从设备3 * 从设备3
*/ */
private String sn3; private String sn3;
/**
* 从设备型号3 1有线 0无线
*/
private Integer deviceType3;
/** /**
* 从设备4 * 从设备4
*/ */
private String sn4; private String sn4;
/**
* 从设备型号4 1有线 0无线
*/
private Integer deviceType4;
/** /**
* 从设备5 * 从设备5
...@@ -70,19 +47,10 @@ public class VehicleInfoVo implements Serializable { ...@@ -70,19 +47,10 @@ public class VehicleInfoVo implements Serializable {
private String sn5; private String sn5;
/** /**
* 从设备型号5 1有线 0无线
*/
private Integer deviceType5;
/**
* 从设备6 * 从设备6
*/ */
private String sn6; private String sn6;
/**
* 从设备型号6 1有线 0无线
*/
private Integer deviceType6;
/** /**
* 从设备7 * 从设备7
...@@ -90,31 +58,16 @@ public class VehicleInfoVo implements Serializable { ...@@ -90,31 +58,16 @@ public class VehicleInfoVo implements Serializable {
private String sn7; private String sn7;
/** /**
* 从设备型号7 1有线 0无线
*/
private Integer deviceType7;
/**
* 从设备8 * 从设备8
*/ */
private String sn8; private String sn8;
/** /**
* 从设备型号8 1有线 0无线
*/
private Integer deviceType8;
/**
* 从设备9 * 从设备9
*/ */
private String sn9; private String sn9;
/** /**
* 从设备型号9 1有线 0无线
*/
private Integer deviceType9;
/**
* 姓名 * 姓名
*/ */
private String ownerName; private String ownerName;
......
package cn.com.glsx.admin.modules.service; package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.common.constants.ConstantsDevice;
import cn.com.glsx.admin.modules.entity.Device; import cn.com.glsx.admin.modules.entity.Device;
import cn.com.glsx.admin.modules.entity.VehicleDevice;
import cn.com.glsx.admin.modules.mapper.DeviceMapper; import cn.com.glsx.admin.modules.mapper.DeviceMapper;
import cn.com.glsx.admin.modules.mapper.VehicleDeviceMapper;
import cn.com.glsx.admin.modules.model.param.TrackInfoBo; import cn.com.glsx.admin.modules.model.param.TrackInfoBo;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import com.glsx.plat.common.utils.StringUtils; import com.glsx.plat.common.utils.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -24,11 +28,36 @@ public class DeviceService { ...@@ -24,11 +28,36 @@ public class DeviceService {
@Autowired @Autowired
private RemoteDeviceService remoteDeviceService; private RemoteDeviceService remoteDeviceService;
@Autowired
private VehicleDeviceMapper vehicleDeviceMapper;
/**
* 插入设备数据
*
* @param device 设备数据
* @return 改变的行数
*/
public int insertDevice(Device device) { public int insertDevice(Device device) {
return deviceMapper.insert(device); return deviceMapper.insert(device);
} }
Device getDeviceBySn(String sn) { /**
* 修改设备数据
*
* @param device 设备数据
* @return 改变的行数
*/
public int updateDevice(Device device) {
return deviceMapper.updateByPrimaryKeySelective(device);
}
/**
* 根据 sn 获取设备信息
*
* @param sn 设备号
* @return 设备信息
*/
public Device getDeviceBySn(String sn) {
return deviceMapper.selectBySn(sn); return deviceMapper.selectBySn(sn);
} }
...@@ -88,4 +117,56 @@ public class DeviceService { ...@@ -88,4 +117,56 @@ public class DeviceService {
device.setDelFlag(0); device.setDelFlag(0);
return deviceMapper.select(device); return deviceMapper.select(device);
} }
/**
* 通过 sn 调用标准接口获取 设备型号
*
* @param sn 设备号
* @return 设备型号
*/
public String getDeviceClassifyNameBysn(String sn) {
return remoteDeviceService.getDeviceClassifyNameBysn(sn);
}
/**
* 检查设备号是否在旧E盾以及新E盾中存在(入库) false 不存在
*
* @param sn 设备号
*/
public boolean checkSnLocalAndRemote(String sn) {
if (StringUtils.isEmpty(sn)) {
return false;
}
Device device = deviceMapper.selectBySn(sn);
if (device == null) {
TrackInfoBo trackInfoBo = remoteDeviceService.getDeviceBySn(sn);
if (trackInfoBo == null) {
return false;
} else {
// 在老E盾库中存在就入库
saveTrackInfoBo(trackInfoBo, ShieldContextHolder.getUserId());
}
}
return true;
}
/**
* 检查设备号是否已经绑定
*
* @param sn 设备号
*/
public boolean checkBindSn(String sn) {
if (StringUtils.isEmpty(sn)) {
return false;
}
VehicleDevice param = new VehicleDevice();
param.setSn(sn);
param.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS);
VehicleDevice vehicleDevice = vehicleDeviceMapper.getVehicleDeviceBySnStatus(param);
if (vehicleDevice == null) {
return true;
}
return false;
}
} }
...@@ -83,6 +83,7 @@ public class ElectricInStoreDriveService { ...@@ -83,6 +83,7 @@ public class ElectricInStoreDriveService {
Integer num29 = null; Integer num29 = null;
Integer num30 = null; Integer num30 = null;
Integer num31 = null; Integer num31 = null;
Integer summation = 0;
if (maxDayNum >= 28) { if (maxDayNum >= 28) {
num28 = 0; num28 = 0;
...@@ -96,6 +97,7 @@ public class ElectricInStoreDriveService { ...@@ -96,6 +97,7 @@ public class ElectricInStoreDriveService {
if (maxDayNum >= 31) { if (maxDayNum >= 31) {
num31 = 0; num31 = 0;
} }
// 组合每一天的数据 // 组合每一天的数据
for (ElectricInStoreDrive inStoreDrive : inStoreDataList) { for (ElectricInStoreDrive inStoreDrive : inStoreDataList) {
// 设置报表统计时间 // 设置报表统计时间
...@@ -105,134 +107,164 @@ public class ElectricInStoreDriveService { ...@@ -105,134 +107,164 @@ public class ElectricInStoreDriveService {
switch (dayOfMonth) { switch (dayOfMonth) {
case 1: case 1:
num1 = getInStoreNum(inStoreDrive, num1); num1 = getInStoreNum(inStoreDrive, num1);
summation = summation + num1;
electricInStoreExport.setDayNum1(num1); electricInStoreExport.setDayNum1(num1);
break; break;
case 2: case 2:
num2 = getInStoreNum(inStoreDrive, num2); num2 = getInStoreNum(inStoreDrive, num2);
summation = summation + num2;
electricInStoreExport.setDayNum2(num2); electricInStoreExport.setDayNum2(num2);
break; break;
case 3: case 3:
num3 = getInStoreNum(inStoreDrive, num3); num3 = getInStoreNum(inStoreDrive, num3);
summation = summation + num3;
electricInStoreExport.setDayNum3(num3); electricInStoreExport.setDayNum3(num3);
break; break;
case 4: case 4:
num4 = getInStoreNum(inStoreDrive, num4); num4 = getInStoreNum(inStoreDrive, num4);
summation = summation + num4;
electricInStoreExport.setDayNum4(num4); electricInStoreExport.setDayNum4(num4);
break; break;
case 5: case 5:
num5 = getInStoreNum(inStoreDrive, num5); num5 = getInStoreNum(inStoreDrive, num5);
summation = summation + num5;
electricInStoreExport.setDayNum5(num5); electricInStoreExport.setDayNum5(num5);
break; break;
case 6: case 6:
num6 = getInStoreNum(inStoreDrive, num6); num6 = getInStoreNum(inStoreDrive, num6);
summation = summation + num6;
electricInStoreExport.setDayNum6(num6); electricInStoreExport.setDayNum6(num6);
break; break;
case 7: case 7:
num7 = getInStoreNum(inStoreDrive, num7); num7 = getInStoreNum(inStoreDrive, num7);
summation = summation + num7;
electricInStoreExport.setDayNum7(num7); electricInStoreExport.setDayNum7(num7);
break; break;
case 8: case 8:
num8 = getInStoreNum(inStoreDrive, num8); num8 = getInStoreNum(inStoreDrive, num8);
summation = summation + num8;
electricInStoreExport.setDayNum8(num8); electricInStoreExport.setDayNum8(num8);
break; break;
case 9: case 9:
num9 = getInStoreNum(inStoreDrive, num9); num9 = getInStoreNum(inStoreDrive, num9);
summation = summation + num9;
electricInStoreExport.setDayNum9(num9); electricInStoreExport.setDayNum9(num9);
break; break;
case 10: case 10:
num10 = getInStoreNum(inStoreDrive, num10); num10 = getInStoreNum(inStoreDrive, num10);
summation = summation + num10;
electricInStoreExport.setDayNum10(num10); electricInStoreExport.setDayNum10(num10);
break; break;
case 11: case 11:
num11 = getInStoreNum(inStoreDrive, num11); num11 = getInStoreNum(inStoreDrive, num11);
summation = summation + num11;
electricInStoreExport.setDayNum11(num11); electricInStoreExport.setDayNum11(num11);
break; break;
case 12: case 12:
num12 = getInStoreNum(inStoreDrive, num12); num12 = getInStoreNum(inStoreDrive, num12);
summation = summation + num12;
electricInStoreExport.setDayNum12(num12); electricInStoreExport.setDayNum12(num12);
break; break;
case 13: case 13:
num13 = getInStoreNum(inStoreDrive, num13); num13 = getInStoreNum(inStoreDrive, num13);
summation = summation + num13;
electricInStoreExport.setDayNum13(num13); electricInStoreExport.setDayNum13(num13);
break; break;
case 14: case 14:
num14 = getInStoreNum(inStoreDrive, num14); num14 = getInStoreNum(inStoreDrive, num14);
summation = summation + num14;
electricInStoreExport.setDayNum14(num14); electricInStoreExport.setDayNum14(num14);
break; break;
case 15: case 15:
num15 = getInStoreNum(inStoreDrive, num15); num15 = getInStoreNum(inStoreDrive, num15);
summation = summation + num15;
electricInStoreExport.setDayNum15(num15); electricInStoreExport.setDayNum15(num15);
break; break;
case 16: case 16:
num16 = getInStoreNum(inStoreDrive, num16); num16 = getInStoreNum(inStoreDrive, num16);
summation = summation + num16;
electricInStoreExport.setDayNum16(num16); electricInStoreExport.setDayNum16(num16);
break; break;
case 17: case 17:
num17 = getInStoreNum(inStoreDrive, num17); num17 = getInStoreNum(inStoreDrive, num17);
summation = summation + num17;
electricInStoreExport.setDayNum17(num17); electricInStoreExport.setDayNum17(num17);
break; break;
case 18: case 18:
num18 = getInStoreNum(inStoreDrive, num18); num18 = getInStoreNum(inStoreDrive, num18);
summation = summation + num18;
electricInStoreExport.setDayNum18(num18); electricInStoreExport.setDayNum18(num18);
break; break;
case 19: case 19:
num19 = getInStoreNum(inStoreDrive, num19); num19 = getInStoreNum(inStoreDrive, num19);
summation = summation + num19;
electricInStoreExport.setDayNum19(num19); electricInStoreExport.setDayNum19(num19);
break; break;
case 20: case 20:
num20 = getInStoreNum(inStoreDrive, num20); num20 = getInStoreNum(inStoreDrive, num20);
summation = summation + num20;
electricInStoreExport.setDayNum20(num20); electricInStoreExport.setDayNum20(num20);
break; break;
case 21: case 21:
num21 = getInStoreNum(inStoreDrive, num21); num21 = getInStoreNum(inStoreDrive, num21);
summation = summation + num21;
electricInStoreExport.setDayNum21(num21); electricInStoreExport.setDayNum21(num21);
break; break;
case 22: case 22:
num22 = getInStoreNum(inStoreDrive, num22); num22 = getInStoreNum(inStoreDrive, num22);
summation = summation + num22;
electricInStoreExport.setDayNum22(num22); electricInStoreExport.setDayNum22(num22);
break; break;
case 23: case 23:
num23 = getInStoreNum(inStoreDrive, num23); num23 = getInStoreNum(inStoreDrive, num23);
summation = summation + num23;
electricInStoreExport.setDayNum23(num23); electricInStoreExport.setDayNum23(num23);
break; break;
case 24: case 24:
num24 = getInStoreNum(inStoreDrive, num24); num24 = getInStoreNum(inStoreDrive, num24);
summation = summation + num24;
electricInStoreExport.setDayNum24(num24); electricInStoreExport.setDayNum24(num24);
break; break;
case 25: case 25:
num25 = getInStoreNum(inStoreDrive, num25); num25 = getInStoreNum(inStoreDrive, num25);
summation = summation + num25;
electricInStoreExport.setDayNum25(num25); electricInStoreExport.setDayNum25(num25);
break; break;
case 26: case 26:
num26 = getInStoreNum(inStoreDrive, num26); num26 = getInStoreNum(inStoreDrive, num26);
summation = summation + num26;
electricInStoreExport.setDayNum26(num26); electricInStoreExport.setDayNum26(num26);
break; break;
case 27: case 27:
num27 = getInStoreNum(inStoreDrive, num27); num27 = getInStoreNum(inStoreDrive, num27);
summation = summation + num27;
electricInStoreExport.setDayNum27(num27); electricInStoreExport.setDayNum27(num27);
break; break;
case 28: case 28:
num28 = getInStoreNum(inStoreDrive, num28); num28 = getInStoreNum(inStoreDrive, num28);
summation = summation + num28;
electricInStoreExport.setDayNum28(num28); electricInStoreExport.setDayNum28(num28);
break; break;
case 29: case 29:
num29 = getInStoreNum(inStoreDrive, num29); num29 = getInStoreNum(inStoreDrive, num29);
summation = summation + num29;
electricInStoreExport.setDayNum29(num29); electricInStoreExport.setDayNum29(num29);
break; break;
case 30: case 30:
num30 = getInStoreNum(inStoreDrive, num30); num30 = getInStoreNum(inStoreDrive, num30);
summation = summation + num30;
electricInStoreExport.setDayNum30(num30); electricInStoreExport.setDayNum30(num30);
break; break;
case 31: case 31:
num31 = getInStoreNum(inStoreDrive, num31); num31 = getInStoreNum(inStoreDrive, num31);
summation = summation + num31;
electricInStoreExport.setDayNum8(num31); electricInStoreExport.setDayNum8(num31);
break; break;
default: default:
log.info("已经超过最大天数"); log.info("已经超过最大天数");
} }
} }
int summation = num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10 + num11 + num12 + num13 + num14 + num15 + num16;
summation = summation + num17 + num18 + num19 + num20 + num21 + num22 + num23 + num24 + num25 + num26 + num27 + num28 + num29 + num30 + num31;
electricInStoreExport.setSummation(summation); electricInStoreExport.setSummation(summation);
electricInStoreExport.setDayNum1(replaceDayNum(electricInStoreExport.getDayNum1())); electricInStoreExport.setDayNum1(replaceDayNum(electricInStoreExport.getDayNum1()));
......
...@@ -7,7 +7,6 @@ import com.glsx.plat.common.utils.HttpUtils; ...@@ -7,7 +7,6 @@ import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.context.utils.PropertiesUtils; import com.glsx.plat.context.utils.PropertiesUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.util.PropertiesUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.TreeMap; import java.util.TreeMap;
...@@ -19,6 +18,7 @@ public class RemoteDeviceService { ...@@ -19,6 +18,7 @@ public class RemoteDeviceService {
/** /**
* 调用e盾标准接口获取设备信息 * 调用e盾标准接口获取设备信息
*
* @param sn * @param sn
*/ */
public TrackInfoBo getDeviceBySn(String sn) { public TrackInfoBo getDeviceBySn(String sn) {
...@@ -50,4 +50,39 @@ public class RemoteDeviceService { ...@@ -50,4 +50,39 @@ public class RemoteDeviceService {
TrackInfoBo trackInfoBo = JSONObject.parseObject(data, TrackInfoBo.class); TrackInfoBo trackInfoBo = JSONObject.parseObject(data, TrackInfoBo.class);
return trackInfoBo; return trackInfoBo;
} }
/**
* 调用e盾标准接口获取设备型号
*
* @param sn 设备号
*/
public String getDeviceClassifyNameBysn(String sn) {
String url = PropertiesUtils.getProperty("edun.otsi.url") + "/api/device/getDeviceClassifyNameBysn";
String appKet = PropertiesUtils.getProperty("edun.otsi.appKet");
String appSecret = PropertiesUtils.getProperty("edun.otsi.appSecret");
TreeMap<String, Object> tparams = new TreeMap<>();
tparams.put("appKey", appKet);
tparams.put("sn", sn);
//加密得到sign
String sign = GopUtil.sign(tparams, appSecret);
tparams.put("sign", sign);
String result = HttpUtils.get(url, tparams);
log.info("getDeviceClassifyNameBysn====result===" + result);
JSONObject resultObj = JSONObject.parseObject(result);
if (resultObj == null) {
log.info("remote getInfoBysn result is null");
return null;
}
String returnCode = resultObj.getString("returnCode");
String message = resultObj.getString("message");
if (StringUtils.isBlank(returnCode) || !"0".equals(returnCode)) {
log.info("remote getInfoBysn fail! returnCode:" + returnCode + "; message:" + message);
return null;
}
String deviceClassifyName = resultObj.getString("data");
if (StringUtils.isBlank(deviceClassifyName)) {
return null;
}
return deviceClassifyName;
}
} }
...@@ -90,8 +90,7 @@ public class VehicleDeviceService { ...@@ -90,8 +90,7 @@ public class VehicleDeviceService {
param.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS); param.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS);
param.setVehicleId(vehicleId); param.setVehicleId(vehicleId);
//匹配设备 //匹配设备
List<VehicleDevice> bindVehicleDevice = vehicleDeviceMapper.getVehicleDeviceByVehicleIdStatus(param); return vehicleDeviceMapper.getVehicleDeviceByVehicleIdStatus(param);
return bindVehicleDevice;
} }
/** /**
...@@ -103,8 +102,7 @@ public class VehicleDeviceService { ...@@ -103,8 +102,7 @@ public class VehicleDeviceService {
VehicleDevice param = new VehicleDevice(); VehicleDevice param = new VehicleDevice();
param.setSn(sn); param.setSn(sn);
param.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS); param.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS);
VehicleDevice vehicleDevice = vehicleDeviceMapper.getVehicleDeviceBySnStatus(param); return vehicleDeviceMapper.getVehicleDeviceBySnStatus(param);
return vehicleDevice;
} }
/** /**
...@@ -146,4 +144,23 @@ public class VehicleDeviceService { ...@@ -146,4 +144,23 @@ public class VehicleDeviceService {
public void unBindByVehicleId(Long id) { public void unBindByVehicleId(Long id) {
vehicleDeviceMapper.unBindByVehicleId(id); vehicleDeviceMapper.unBindByVehicleId(id);
} }
public VehicleDevice getTrialDeviceBySn(String sn) {
VehicleDevice param = new VehicleDevice();
param.setSn(sn);
param.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS);
param.setTrialType(ConstantsDevice.TRIAL_DEVICE_STATUS);
param.setDelFlag(ConstantsDevice.NOT_DEL_FLAG);
return vehicleDeviceMapper.selectOne(param);
}
public List<VehicleDevice> listTrialDeviceByVehicleIdBind(Long vehicleId) {
VehicleDevice param = new VehicleDevice();
param.setVehicleId(vehicleId);
param.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS);
param.setTrialType(ConstantsDevice.TRIAL_DEVICE_STATUS);
param.setDelFlag(ConstantsDevice.NOT_DEL_FLAG);
//匹配设备
return vehicleDeviceMapper.select(param);
}
} }
...@@ -432,21 +432,19 @@ public class VehicleService { ...@@ -432,21 +432,19 @@ public class VehicleService {
/** /**
* 先删除试驾车辆 再删除绑定关系 * 先删除试驾车辆 再删除绑定关系
* *
* @param tempId * @param vehicleId 车辆ID
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteDriveVehicleAndUnBind(String tempId) { public void deleteDriveVehicleAndUnBind(String vehicleId) {
// 删除车辆表中的数据 状态标记为删除
deleteDriveVehicle(Long.parseLong(tempId));
// 删除试驾车辆关系表中的数据 状态标记为删除 // 删除试驾车辆关系表中的数据 状态标记为删除
deleteTrialDriveVehicle(Long.parseLong(tempId)); deleteTrialDriveVehicle(Long.parseLong(vehicleId));
// 查询关联的设备进行解绑 // 查询与车架号关联 且是试驾设备的列表
List<VehicleDevice> vehicleDeviceList = vehicleDeviceService.listVehicleDeviceByVehicleIdBind(Long.parseLong(tempId)); List<VehicleDevice> vehicleDeviceList = vehicleDeviceService.listTrialDeviceByVehicleIdBind(Long.parseLong(vehicleId));
for (VehicleDevice vehicleDevice : vehicleDeviceList) { for (VehicleDevice vehicleDevice : vehicleDeviceList) {
vehicleDevice.setUpdatedDate(new Date()); vehicleDevice.setUpdatedDate(new Date());
vehicleDevice.setUpdatedBy(ShieldContextHolder.getUserId()); vehicleDevice.setUpdatedBy(ShieldContextHolder.getUserId());
vehicleDevice.setBindStatus(ConstantsDevice.UN_BIND_VEHICLE_STATUS); //试驾设备标记为非试驾设备
vehicleDevice.setDelFlag(Constants.DELETE_FLAG); vehicleDevice.setTrialType(ConstantsDevice.NOT_TRIAL_DEVICE_STATUS);
vehicleDeviceService.updateByPrimaryKey(vehicleDevice); vehicleDeviceService.updateByPrimaryKey(vehicleDevice);
} }
} }
...@@ -1187,14 +1185,22 @@ public class VehicleService { ...@@ -1187,14 +1185,22 @@ public class VehicleService {
return vehicleMapper.listTestDriveVehicle(); return vehicleMapper.listTestDriveVehicle();
} }
public void addTestDriveVehicle(List<Long> vehicleIds) { @Transactional
for (Long id : vehicleIds) { public void addTestDriveVehicle(TestVehicleVo testVehicleVo) {
TrialDriveVehicle trialDriveVehicle = new TrialDriveVehicle(); TrialDriveVehicle trialDriveVehicle = new TrialDriveVehicle();
trialDriveVehicle.setVehicleId(id); trialDriveVehicle.setVehicleId(testVehicleVo.getId());
trialDriveVehicle.setDelFlag(0); trialDriveVehicle.setDelFlag(0);
trialDriveVehicle.setCreatedDate(new Date()); trialDriveVehicle.setCreatedDate(new Date());
trialDriveVehicle.setCreatedBy(ShieldContextHolder.getUserId()); trialDriveVehicle.setCreatedBy(ShieldContextHolder.getUserId());
trialDriveVehicleMapper.insertSelective(trialDriveVehicle); trialDriveVehicleMapper.insertSelective(trialDriveVehicle);
} VehicleDevice vehicleDevice = vehicleDeviceService.getVehicleDeviceBySnBind(testVehicleVo.getSn());
vehicleDevice.setTrialType(1);
vehicleDeviceService.updateByPrimaryKey(vehicleDevice);
}
public void removeTrialSn(String sn) {
VehicleDevice vehicleDevice = vehicleDeviceService.getTrialDeviceBySn(sn);
vehicleDevice.setTrialType(ConstantsDevice.NOT_TRIAL_DEVICE_STATUS);
vehicleDeviceService.updateByPrimaryKey(vehicleDevice);
} }
} }
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
from t_vehicle tv from t_vehicle tv
inner join t_electric_fence_sns tefs on tv.vin = tefs.vin inner join t_electric_fence_sns tefs on tv.vin = tefs.vin
inner join t_electric_fence tef on tef.id = tefs.fence_id inner join t_electric_fence tef on tef.id = tefs.fence_id
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_user tu on tu.id = tef.created_by left join t_user tu on tu.id = tef.created_by
where tef.biz_fence_type = 12 where tef.biz_fence_type = 12
and tu.del_flag = 0 and tu.del_flag = 0
and ttdv.del_flag = 0 and tvd.trial_type = 1
<if test="keywords != null and keywords!='' "> <if test="keywords != null and keywords!='' ">
and ( and (
tu.account like '%${keywords}%' tu.account like '%${keywords}%'
...@@ -69,9 +69,7 @@ ...@@ -69,9 +69,7 @@
</if> </if>
</otherwise> </otherwise>
</choose> </choose>
<if test="sn !=null and sn != ''"> and teid.sn = #{sn}
and teid.sn = #{sn}
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<result column="sn" jdbcType="VARCHAR" property="sn"/> <result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="vin" jdbcType="VARCHAR" property="vin"/> <result column="vin" jdbcType="VARCHAR" property="vin"/>
<result column="statDate" jdbcType="VARCHAR" property="statDate"/> <result column="statDate" jdbcType="VARCHAR" property="statDate"/>
<result column="cnt" jdbcType="INTEGER" property="cnt"/>
<result column="dayCount" jdbcType="INTEGER" property="dayCount"/> <result column="dayCount" jdbcType="INTEGER" property="dayCount"/>
<result column="cnttotal" jdbcType="INTEGER" property="cnttotal"/> <result column="cnttotal" jdbcType="INTEGER" property="cnttotal"/>
</resultMap> </resultMap>
...@@ -35,11 +34,11 @@ ...@@ -35,11 +34,11 @@
from t_vehicle tv from t_vehicle tv
inner join t_electric_fence_sns tefs on tv.vin = tefs.vin inner join t_electric_fence_sns tefs on tv.vin = tefs.vin
inner join t_electric_fence tef on tef.id = tefs.fence_id inner join t_electric_fence tef on tef.id = tefs.fence_id
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_user tu on tu.id = tef.created_by left join t_user tu on tu.id = tef.created_by
where tef.del_flag = 0 where tef.del_flag = 0
and tef.biz_fence_type = 12 and tef.biz_fence_type = 12
and ttdv.del_flag = 0 and tvd.trial_type = 1
<if test="keywords != null and keywords!='' "> <if test="keywords != null and keywords!='' ">
and ( and (
tu.account like '%${keywords}%' tu.account like '%${keywords}%'
...@@ -69,10 +68,7 @@ ...@@ -69,10 +68,7 @@
</if> </if>
</otherwise> </otherwise>
</choose> </choose>
and tsfd.sn = #{sn}
<if test="sn != null and sn !=''">
and tsfd.sn = #{sn}
</if>
</where> </where>
</select> </select>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<result column="sn" jdbcType="VARCHAR" property="sn"/> <result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="bind_status" jdbcType="TINYINT" property="bindStatus"/> <result column="bind_status" jdbcType="TINYINT" property="bindStatus"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/> <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="trial_type" jdbcType="TINYINT" property="trialType"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/> <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/> <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/> <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
tvd.created_date installedTime tvd.created_date installedTime
from t_vehicle tv from t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0 left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0 and tvd.trial_type = 1
left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0 left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0
left join t_trial_drive_shop ttds on tu.id = ttds.created_by and ttds.del_flag = 0 left join t_trial_drive_shop ttds on tu.id = ttds.created_by and ttds.del_flag = 0
where tv.del_flag = 0 where tv.del_flag = 0
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
tu.username shopName, tu.account shopCode, tu.username shopName, tu.account shopCode,
group_concat(tvd.sn) sns group_concat(tvd.sn) sns
from t_vehicle tv from t_vehicle tv
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0 left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0 and tvd.trial_type = 1
left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0 left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0
left join t_trial_drive_shop ttds on tu.id = ttds.created_by and ttds.del_flag = 0 left join t_trial_drive_shop ttds on tu.id = ttds.created_by and ttds.del_flag = 0
where tv.del_flag = 0 where tv.del_flag = 0
...@@ -346,9 +346,11 @@ ...@@ -346,9 +346,11 @@
</select> </select>
<select id="listTestDriveVehicle" resultType="cn.com.glsx.admin.modules.model.TestVehicleVo"> <select id="listTestDriveVehicle" resultType="cn.com.glsx.admin.modules.model.TestVehicleVo">
select tv.id ,tv.vin ,tv.owner_name select tv.id ,tv.vin ,tv.owner_name ,td.sn ,td.source
from t_vehicle tv from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device td on td.sn = tvd.sn
where tv.del_flag = 0 where tv.del_flag = 0
and tv.id not in (select vehicle_id from t_trial_drive_vehicle) and tvd.trial_type = 0
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,7 @@ import cn.com.glsx.usercenter.api.feign.OrganizationService; ...@@ -8,6 +8,7 @@ import cn.com.glsx.usercenter.api.feign.OrganizationService;
import cn.com.glsx.usercenter.api.feign.UserService; import cn.com.glsx.usercenter.api.feign.UserService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.glsx.plat.common.utils.DateUtils; import com.glsx.plat.common.utils.DateUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
...@@ -21,6 +22,7 @@ import java.util.ArrayList; ...@@ -21,6 +22,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
...@@ -90,4 +92,25 @@ public class TrialDriveReportServiceTest { ...@@ -90,4 +92,25 @@ public class TrialDriveReportServiceTest {
List<TrialDriveReportExport> testDriveData = trialDriveReportService.search(search); List<TrialDriveReportExport> testDriveData = trialDriveReportService.search(search);
System.out.println("testDriveData = " + JSON.toJSONString(testDriveData)); System.out.println("testDriveData = " + JSON.toJSONString(testDriveData));
} }
@Test
public void test08() {
ArrayList<String> strings = new ArrayList<>();
strings.add(null);
strings.add(null);
strings.add(null);
strings.add(null);
strings.add(null);
List<String> collect = strings.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
System.out.println("strings = " + JSON.toJSONString(collect));
}
@Test
public void test09() {
Integer a = 1;
Integer b = null;
System.out.println(a + b);
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!