| | |
| | | import android.view.ViewGroup; |
| | | import android.widget.Button; |
| | | import android.widget.EditText; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | |
| | | 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.LogUtils; |
| | | import com.blankj.utilcode.util.ScreenUtils; |
| | | import com.blankj.utilcode.util.TimeUtils; |
| | | import com.lotaai.canguiayw.device.CanguiStatus; |
| | | import com.lotaai.canguiayw.device.service.CrontrolGridModel; |
| | | import com.lotaai.canguiayw.sqllitedb.GridModel; |
| | | import com.lotaai.canguiayw.sqllitedb.Order; |
| | | import com.lotaai.canguiayw.sqllitedb.OrderDetail; |
| | | import com.lotaai.canguiayw.sqllitedb.SqlliteDbManage; |
| | | import com.pranavpandey.android.dynamic.toasts.DynamicToast; |
| | | |
| | | import org.w3c.dom.Text; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | private Context context; |
| | | private EditText editText; |
| | | private SmartTable orderDetailTable; |
| | | private TextView gekouTxt; |
| | | private TextView orderNotxt; |
| | | |
| | | @Override |
| | | public void onCreate(Bundle savedInstanceState) { |
| | |
| | | if (root == null) { |
| | | root = inflater.inflate(R.layout.framgment_cuncan, container, false); |
| | | } |
| | | DynamicToast.Config.getInstance().setTextSize(30).apply(); |
| | | context = container.getContext(); |
| | | editText = (EditText)root.findViewById(R.id.edt_borrow_case_number); |
| | | gekouTxt = root.findViewById(R.id.geKoueText); |
| | | orderNotxt = root.findViewById(R.id.orderNoText); |
| | | editText.setInputType(InputType.TYPE_NULL); // 屏蔽软键盘 |
| | | View.OnClickListener clickListener = new View.OnClickListener() { |
| | | @Override |
| | |
| | | // 调用后台 |
| | | String gridNo = editable.toString(); |
| | | if (null == gridNo || "".equals(gridNo.trim())) { |
| | | Toast.makeText(context, "取餐码不能为空。", Toast.LENGTH_SHORT).show(); |
| | | DynamicToast.makeError(context, "取餐序号不能为空。", 3).show(); |
| | | return; |
| | | } else { |
| | | if (gridNo.length() > 5) { |
| | | Toast.makeText(context, "取餐码输入错误,请重试。", Toast.LENGTH_SHORT).show(); |
| | | if (gridNo.length() !=4) { |
| | | editText.setText(""); |
| | | DynamicToast.makeError(context, "取餐序号输入错误,请重试。", 3).show(); |
| | | return; |
| | | } |
| | | } |
| | | //处理存餐的问题 |
| | | //1、查询订单,并判断是否已经存过餐,如果存过 |
| | | Order od = SqlliteDbManage.getInstance().selectOrtderByXuhao(gridNo); |
| | | if (od!=null){ |
| | | if (od.getState() == 0 || od.getState() == 1){ |
| | | LogUtils.i("orderNo:" + od.getOrderNo() + " state:" + od.getState()); |
| | | } |
| | | initOrderDetailTableView(od.getOrderNo()); |
| | | }else { |
| | | DynamicToast.makeError(context, "取餐序号输入错误,请重试。", 3).show(); |
| | | initOrderDetailTableView(""); |
| | | } |
| | | //2、分配格子 |
| | | |
| | | |
| | | } else { |
| | | Button button = (Button) v; |
| | | editable.insert(index, button.getText()); |
| | |
| | | view0.setOnClickListener(clickListener); |
| | | view11.setOnClickListener(clickListener); |
| | | view12.setOnClickListener(clickListener); |
| | | |
| | | //初始化ttable |
| | | initOrderDetailTableView(); |
| | | initOrderDetailTableView(""); |
| | | return root; |
| | | } |
| | | |
| | | |
| | | public void initOrderDetailTableView(){ |
| | | Column<String> xuhaoCol = new Column<>("", "gridNo"); |
| | | xuhaoCol.setMinWidth(10); |
| | | xuhaoCol.setComputeWidth(1); |
| | | Column<String> nameCol = new Column<>("名称", "orderNo"); |
| | | public void initOrderDetailTableView(String orderNo){ |
| | | editText.setText(""); |
| | | gekouTxt.setText(""); |
| | | orderNotxt.setText(""); |
| | | Column<String> nameCol = new Column<>("名称", "itemName"); |
| | | nameCol.setComputeWidth(10); |
| | | Column<String> numCol = new Column<>("量", "putInDate"); |
| | | Column<String> numCol = new Column<>("量", "num"); |
| | | numCol.setWidth(10); |
| | | nameCol.setComputeWidth(1); |
| | | |
| | | List<Order> lists = new ArrayList<>(); |
| | | // for (int i = 1;i <= 20; i++) { |
| | | // Order order = new Order(); |
| | | // order.setGridNo(Integer.toString(i)); |
| | | // order.setOrderNo("new year char grenn" ); |
| | | // Date dd = new Date(); |
| | | // order.setPutInDate(6); |
| | | // order.setState(0); |
| | | // order.setTakeCode("56897"); |
| | | // lists.add(order); |
| | | // } |
| | | List<OrderDetail> details = new ArrayList<>(); |
| | | if (!"".equals(orderNo)) { |
| | | details = SqlliteDbManage.getInstance().selectOrtderDetails(orderNo); |
| | | if (details!=null && details.size()>0){ |
| | | //查找空余的格子进行分配 |
| | | GridModel model = SqlliteDbManage.getInstance().selectFreeGrid(); |
| | | gekouTxt.setText(CrontrolGridModel.getGridNoStr(model.getGuiHao(),model.getGridNo())); |
| | | model.setState(1); |
| | | SqlliteDbManage.getInstance().addGrid(model); |
| | | //需要把order数据更新了 |
| | | Order od = SqlliteDbManage.getInstance().selectOrtder(orderNo); |
| | | od.setGridNo(CrontrolGridModel.getGridNoStr(model.getGuiHao(),model.getGridNo())); |
| | | od.setPutInDate(TimeUtils.getNowString()); |
| | | od.setState(1); |
| | | SqlliteDbManage.getInstance().insertOrderInfo(od); |
| | | orderNotxt.setText(orderNo); |
| | | }else { |
| | | DynamicToast.makeError(context, "未查询到订单", 3).show(); |
| | | } |
| | | } |
| | | |
| | | TableData<Order> tableData = new TableData<Order>("订单详情",lists, xuhaoCol,nameCol, numCol); |
| | | TableData<OrderDetail> tableData = new TableData<OrderDetail>("订单详情",details,nameCol, numCol); |
| | | //设置数据 |
| | | orderDetailTable = root.findViewById(R.id.table); |
| | | orderDetailTable.getConfig().setShowTableTitle(true); |