Commit 802ae99a by levphon

工单标准接口

1 parent 9847b381
......@@ -5,6 +5,7 @@ import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
......@@ -20,4 +21,6 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
List<VehicleDevice> selectAllBindingDevices();
List<VehicleDevice> selectBindingDevices(@Param("sns") Collection<String> sns);
}
......@@ -35,6 +35,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -359,6 +361,8 @@ public class WorkOrderService {
checkWorkOrder(workOrder);
checkWorkOrderDevices(verifyBO.getDevices());
List<DeviceLocationItem> devices = Lists.newArrayList();
//目前只有GPS设备
verifyBO.getDevices().forEach(device -> {
......@@ -413,6 +417,25 @@ public class WorkOrderService {
}
/**
* 验证设备存在、激活等状态
*
* @param devices
*/
private void checkWorkOrderDevices(List<SimpleDeviceItem> devices) {
if (CollectionUtils.isEmpty(devices)) {
throw new StdInterfaceException("656565", "验证设备不能为空");
}
Set<String> snSet = devices.stream().map(SimpleDeviceItem::getSn).collect(Collectors.toSet());
List<VehicleDevice> vdList = vehicleDeviceMapper.selectBindingDevices(snSet);
if (vdList.size() > 0) {
throw new StdInterfaceException("656565", "验证设备不能为空");
}
}
/**
* 激活工单信息,激活是以车为单位,不是以工单,一个工单可以包含多辆车
*
* @param orderReq
......@@ -487,6 +510,8 @@ public class WorkOrderService {
});
vehicleDeviceMapper.insertList(devices);
}
// TODO: 2021/12/22 通知e盾库
return activatedDevices;
}
......
......@@ -42,4 +42,16 @@
where del_flag = 0
and bind_status = 1
</select>
<select id="selectBindingDevices" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_vehicle_device
where del_flag = 0
and bind_status = 1
and sn in
<foreach collection="sns" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</select>
</mapper>
\ 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!