Commit d75e3b3f by 向延琳

增加唯一性校验

1 parent d6bf9868
...@@ -3,6 +3,9 @@ package cn.com.glsx.stdinterface.modules.mapper; ...@@ -3,6 +3,9 @@ package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.entity.DeviceJourney; import cn.com.glsx.stdinterface.modules.entity.DeviceJourney;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/** /**
* 新e盾|里程表 * 新e盾|里程表
...@@ -12,4 +15,12 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -12,4 +15,12 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface DeviceJourneyMapper extends CommonBaseMapper<DeviceJourney> { public interface DeviceJourneyMapper extends CommonBaseMapper<DeviceJourney> {
/**
* 根据开始时间和sn查找
* @param sn 设备号
* @param beginTime 开始时间
* @return 设备行程信息
*/
DeviceJourney selectBySnAndBeginTime(@Param("sn")String sn, @Param("beginTime")Date beginTime);
} }
\ No newline at end of file \ No newline at end of file
...@@ -48,6 +48,12 @@ public class JourneyService { ...@@ -48,6 +48,12 @@ public class JourneyService {
if (Objects.isNull(deviceJourneyDTO)) { if (Objects.isNull(deviceJourneyDTO)) {
return; return;
} }
DeviceJourney journey = deviceJourneyMapper.selectBySnAndBeginTime(deviceJourneyDTO.getSn(), deviceJourneyDTO.getBeginTime());
if(Objects.nonNull(journey)) {
log.warn("该设备同样的开始时间行程数据已经存在" +
"sn: " + deviceJourneyDTO.getSn() + "beginTime:" + deviceJourneyDTO.getBeginTime());
return;
}
//从车辆信息中获取创建人信息 //从车辆信息中获取创建人信息
Vehicle vehicle = getVehicleBySn(deviceJourneyDTO.getSn()); Vehicle vehicle = getVehicleBySn(deviceJourneyDTO.getSn());
if (Objects.isNull(vehicle)) { if (Objects.isNull(vehicle)) {
......
...@@ -26,4 +26,15 @@ ...@@ -26,4 +26,15 @@
id, sn, vd_id, begin_time, end_time, begin_address, end_address, mileage, del_flag, id, sn, vd_id, begin_time, end_time, begin_address, end_address, mileage, del_flag,
created_date, created_by, updated_date, updated_by created_date, created_by, updated_date, updated_by
</sql> </sql>
<select id="selectBySnAndBeginTime" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_device_journey
<where>
and sn = #{sn}
and begin_time = #{beginTime}
</where>
limit 1
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!