| | |
| | | import android.graphics.Paint; |
| | | import android.graphics.Rect; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.Editable; |
| | | import android.text.InputType; |
| | | import android.view.LayoutInflater; |
| | |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.bin.david.form.core.SmartTable; |
| | | import com.bin.david.form.core.TableConfig; |
| | | import com.bin.david.form.data.CellInfo; |
| | |
| | | import com.bin.david.form.data.format.draw.IDrawFormat; |
| | | import com.bin.david.form.data.style.FontStyle; |
| | | import com.bin.david.form.data.table.TableData; |
| | | import com.blankj.utilcode.util.CacheDiskUtils; |
| | | import com.blankj.utilcode.util.DeviceUtils; |
| | | import com.blankj.utilcode.util.LogUtils; |
| | | import com.blankj.utilcode.util.ScreenUtils; |
| | | import com.blankj.utilcode.util.TimeUtils; |
| | | import com.lotaai.canguiayw.common.HttpLoggerInterceptor; |
| | | import com.lotaai.canguiayw.common.HttpUrlDefine; |
| | | import com.lotaai.canguiayw.common.SettingConfig; |
| | | import com.lotaai.canguiayw.device.CanguiStatus; |
| | | import com.lotaai.canguiayw.device.service.CrontrolGridModel; |
| | | import com.lotaai.canguiayw.sqllitedb.GridModel; |
| | |
| | | |
| | | import org.w3c.dom.Text; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import okhttp3.Call; |
| | | import okhttp3.Callback; |
| | | import okhttp3.FormBody; |
| | | import okhttp3.OkHttpClient; |
| | | import okhttp3.Request; |
| | | import okhttp3.RequestBody; |
| | | import okhttp3.Response; |
| | | |
| | | public class CunCanFragment extends Fragment { |
| | | |
| | |
| | | } |
| | | initOrderDetailTableView(od.getOrderNo()); |
| | | }else { |
| | | DynamicToast.makeError(context, "取餐序号输入错误,请重试。", 3).show(); |
| | | DynamicToast.makeError(context, "取餐序号不存在,请重试。", 3).show(); |
| | | initOrderDetailTableView(""); |
| | | } |
| | | //2、分配格子 |
| | | |
| | | |
| | | } else { |
| | | Button button = (Button) v; |
| | | editable.insert(index, button.getText()); |
| | |
| | | if (details!=null && details.size()>0){ |
| | | //查找空余的格子进行分配 |
| | | GridModel model = SqlliteDbManage.getInstance().selectFreeGrid(); |
| | | gekouTxt.setText(CrontrolGridModel.getGridNoStr(model.getGuiHao(),model.getGridNo())); |
| | | String gStr = CrontrolGridModel.getGridNoStr(model.getGuiHao(),model.getGridNo()); |
| | | gekouTxt.setText(gStr); |
| | | orderNotxt.setText(orderNo); |
| | | model.setState(1); |
| | | SqlliteDbManage.getInstance().addGrid(model); |
| | | //需要把order数据更新了 |
| | |
| | | od.setGridNo(CrontrolGridModel.getGridNoStr(model.getGuiHao(),model.getGridNo())); |
| | | od.setPutInDate(TimeUtils.getNowString()); |
| | | od.setState(1); |
| | | od.setGridNo(gStr); |
| | | SqlliteDbManage.getInstance().insertOrderInfo(od); |
| | | orderNotxt.setText(orderNo); |
| | | //需要将存餐信息同步到服务端 |
| | | cuncan(gStr,od.getOrderId()); |
| | | |
| | | }else { |
| | | DynamicToast.makeError(context, "未查询到订单", 3).show(); |
| | | } |
| | |
| | | orderDetailTable.setTableData(tableData); |
| | | |
| | | } |
| | | |
| | | |
| | | public void cuncan(String gridNo,String orderId) { |
| | | HttpLoggerInterceptor loggingInterceptor = new HttpLoggerInterceptor(true); |
| | | OkHttpClient client = new OkHttpClient.Builder() |
| | | .connectTimeout(20, TimeUnit.SECONDS)//响应时间,读取时间 |
| | | .readTimeout(20, TimeUnit.SECONDS) |
| | | .callTimeout(20, TimeUnit.SECONDS) |
| | | .addInterceptor(loggingInterceptor)//添加日志拦截器 |
| | | .build(); |
| | | |
| | | RequestBody body = new FormBody.Builder() |
| | | .add("equipmentUid", DeviceUtils.getUniqueDeviceId()) |
| | | .add("gridNo", gridNo) |
| | | .add("orderId", orderId).build(); |
| | | final Request request = new Request.Builder() |
| | | .url(HttpUrlDefine.equipmentCunCan) |
| | | .addHeader("language", "zh-CN") |
| | | .post(body) |
| | | .build(); |
| | | client.newCall(request).enqueue(new Callback() { |
| | | @Override |
| | | public void onFailure(Call call, IOException e) { |
| | | Message message = new Message(); |
| | | message.what = 0; |
| | | message.obj = "存餐同步失败!"; |
| | | showHandler.sendMessage(message); |
| | | } |
| | | |
| | | @Override |
| | | public void onResponse(Call call, Response response) throws IOException { |
| | | String result = response.body().string(); |
| | | LogUtils.i("获取到的数据:"+result); |
| | | JSONObject obj = JSONObject.parseObject(result); |
| | | if ("0".equals(obj.getString("code"))) { |
| | | JSONObject dataObj = obj.getJSONObject("data"); |
| | | // if (dataObj!=null) { |
| | | // String orderId = dataObj.getString("orderId"); |
| | | // String orderId = dataObj.getString("orderId"); |
| | | // } |
| | | } else { |
| | | String string = obj.getString("msg"); |
| | | Message message = new Message(); |
| | | message.what = 0; |
| | | message.obj = "存餐失败:" +string; |
| | | showHandler.sendMessage(message); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private Handler showHandler = new Handler() { |
| | | @Override |
| | | public void handleMessage(Message msg) { |
| | | if (msg.what == 0) { |
| | | DynamicToast.makeError(context, msg.obj.toString(), 3).show(); |
| | | } else if (msg.what == 1) { |
| | | DynamicToast.makeSuccess(context, msg.obj.toString(), 3).show(); |
| | | } else { |
| | | DynamicToast.makeWarning(context, msg.obj.toString(), 3).show(); |
| | | } |
| | | } |
| | | }; |
| | | } |