PHP移动数据收集器
我在一家港口公司工作,该公司开发管理港口运营的软件。我目前正在开发一个数据收集器项目。
数据收集器是一种用于收集信息的便携式设备,然后将其用于特定系统、库存控制、消耗控制、一般报告。
是的,我正在用 php 开发一个软件,以便操作员可以管理集装箱港口以及在港口庭院中进行的其他操作。
在那之前我完全没有问题,但是由于港口庭院是一个受到很多干扰因素的地方,因此可能会发生信号丢失,因为工作应用程序需要有Wi-Fi连接。当它与 php 服务器失去通信时,应用程序将停止工作。
我们曾考虑过在每个收集器上安装一个 apache 服务器,但意识到这是不可行的。
所以我来问你一个建议,如果可能发生信号丢失,我会保存用户输入的数据。
I work in a port company that develops software to manage port operations. I am currently developing a project for data collectors.
Data Collector is a portable device used to collect information, which will then be used in a specific system, inventory control, consumption control, reporting in general.
That's right, I am developing a software in php so that operators can manage container ports and other operations that take place in the courtyard of the ports.
Until then I have no problem at all, but as the courtyard of a port is a place subject to much interference factor,signal loss can occur, since the application to work needs to have wi-fi connection. When it loses communication with the php server the application stops working.
We have thought about installing an apache server on each collector, but realize that this is not feasible.
So I come to ask you a suggestion as I would to save the data input by users if a possible signal loss happened.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您至少对客户端设备有一定的控制权,因此可以确保它们使用的是现代浏览器。因此,您可以使用 HTML5 数据存储(Javascript 中的 localStorage 对象)来记录客户端设备上的数据。当他们按下按钮、填写表格或其他任何内容时,不是将数据上传到服务器,而是使用 Javascript 将其写入本地存储。完成后,查看是否可以将本地存储的内容上传到服务器(使用 Ajax)。如果可以的话,很好,将其从本地存储中删除;如果没有,请将其留在那里以供下次尝试。
我认为,您需要添加一个按钮来刷新任何剩余数据,并训练他们在返回基地时使用它,否则数据将保持未上传状态。那个按钮,也许是整个界面,需要指示是否成功以及还有多少内容尚未上传。或者也许让数据收集页面定期尝试上传任何未完成的数据。如果他们(尝试)转到数据上传未完成的其他页面,就会出现问题 - 您可以通过在离开页面时使用 JavaScript 事件来在某种程度上警告他们,该事件可以告诉他们“数据上传未完成”。由于存储是永久性的,因此甚至可以关闭浏览器或关闭设备,并稍后在范围内重新打开数据采集页面以完成上传 - 主要问题是确保这确实完成的人为因素。
此外,您还需要一种可靠的方法来检查两端是否同意数据已上传。仅仅依赖 Ajax 调用的成功响应或缺乏响应是不够的,因为即使数据已成功上传,您也可能永远不会看到它。一种方法可能是在浏览器端用 ID 标记数据(可能基于会话 ID 和时间),这样如果没有从服务器得到肯定的响应,您就认为在浏览器端失败了,但是如果它实际上没有失败,服务器已经存储了 id,因此稍后再次上传的相同数据将被视为已经完成,因此不会处理两次。
这样做的另一个优点是,即使您在范围内但链接速度较慢,用户也不必等待上传完成即可继续下一个数据输入。
I assume that you have at least some control over the client devices and can therefore be sure they are using a modern browser. Therefore you could use HTML5 data storage (the localStorage object in Javascript) to record the data on the client device. When they press the buttons, fill the forms or whatever, rather than uploading data to the server, write it to local storage using Javascript. When you've done that, see if you can upload the contents of local storage to the server (using Ajax). If you can, great, remove it from the local storage; if not leave it there for the next attempt.
You'll need to add a button to flush any remaining data, I think, and train them to use it on return to base, otherwise data would remain not uploaded. And that button, maybe the whole interface, would need an indication of success and maybe how much hasn't been uploaded. Or maybe have the data collection page periodically try to upload any outstanding data. The problem with that arises if they (try to) go off to some other page with data uploads outstanding - you can warn them to some extent by having a javascript event on leaving the page which can tell them "data upload outstanding". Because the storage is permanent, it is possible to even close the browser or turn the device off, and reopen the data acquisition page later when in range to complete the upload - the main issue is the human factor in making sure this does actually get done.
And also, you'll need a reliable way of checking that both ends agree the data has been uploaded. It won't be good enough to just rely on a successful response or lack of from the Ajax call, because you may never see it even if the data was successfully uploaded. One way might be to tag the data with an ID at the browser end (perhaps based on session ID and time) so that if you don't get an affirmative response from the server, you think it has failed at the browser end, but if it didn't actually fail the server has stored the id, so the same data uploaded again later will be seen as having already completed so not processed twice.
Another advantage of doing it this way is that even if you are within range but on a slow link, the user doesn't have to wait for the upload to complete before proceeding with the next data entry.