|
|
@@ -0,0 +1,370 @@
|
|
|
+package com.uas.rxusames.fragment;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Intent;
|
|
|
+import android.support.v7.widget.DefaultItemAnimator;
|
|
|
+import android.support.v7.widget.DividerItemDecoration;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.Log;
|
|
|
+import android.util.SparseBooleanArray;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
+import com.uas.rxusames.R;
|
|
|
+import com.uas.rxusames.activity.FunctionActivity;
|
|
|
+import com.uas.rxusames.bean.MaintainitemBean;
|
|
|
+import com.uas.rxusames.global.GloableParams;
|
|
|
+import com.uas.rxusames.tools.SharedPreUtil;
|
|
|
+import com.uas.rxusames.util.CommonUtil;
|
|
|
+import com.uas.rxusames.util.FastjsonUtil;
|
|
|
+import com.uas.rxusames.util.HttpCallback;
|
|
|
+import com.uas.rxusames.util.HttpParams;
|
|
|
+import com.uas.rxusames.util.LogUtil;
|
|
|
+import com.uas.rxusames.util.VollyRequest;
|
|
|
+
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by RaoMeng on 2024/05/27
|
|
|
+ * Desc: 预加工报工
|
|
|
+ */
|
|
|
+public class PreProcessingReportFragment extends BaseFragment implements View.OnClickListener{
|
|
|
+
|
|
|
+ private RecyclerView mRecyclerView;
|
|
|
+ private ArrayList<MaintainitemBean> mFeededList;
|
|
|
+ private SelectAdapter myAdapter;
|
|
|
+ private Button jlt_storage_in_barcode_save_btn;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private String ma_code;
|
|
|
+ private String sc_code;
|
|
|
+ private TextView tv_ma_code;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_pre_processing_report;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ setTitle("预加工报工");
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ mRecyclerView = root.findViewById(R.id.feeded_rv);
|
|
|
+ tv_ma_code = root.findViewById(R.id.tv_ma_code);
|
|
|
+ jlt_storage_in_barcode_save_btn = root.findViewById(R.id.jlt_storage_in_barcode_save_btn);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ jlt_storage_in_barcode_save_btn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ ArrayList<MaintainitemBean> selectedItem = myAdapter.getSelectedItem();
|
|
|
+ if (selectedItem==null||selectedItem.size()==0){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请选择料号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String sunmdata = "";
|
|
|
+ for (int i=0;i<selectedItem.size();i++){
|
|
|
+ MaintainitemBean maintainitemBean = selectedItem.get(i);
|
|
|
+ sunmdata+=maintainitemBean.getMM_PRODCODE()+",";
|
|
|
+ }
|
|
|
+ Log.e("liao_code",sunmdata);
|
|
|
+
|
|
|
+ getNewsave(sunmdata);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ma_code = SharedPreUtil.getString(mActivity, "MA_CODE", null);
|
|
|
+ sc_code = SharedPreUtil.getString(mActivity, "SC_CODE", null);
|
|
|
+ tv_ma_code.setText(ma_code);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ mFeededList = new ArrayList<>();
|
|
|
+ myAdapter = new SelectAdapter(mFeededList);
|
|
|
+ mRecyclerView = root.findViewById(R.id.feeded_rv);
|
|
|
+ mRecyclerView.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayout.VERTICAL));
|
|
|
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ //设置Item增加、移除动画
|
|
|
+ mRecyclerView.setItemAnimator(new DefaultItemAnimator());
|
|
|
+ setAdapter(mFeededList);
|
|
|
+ mRecyclerView.setAdapter(myAdapter);
|
|
|
+ getNewVersionMsg();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getNewVersionMsg() {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_GETMAKEMATERIAL)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("ma_code",ma_code)
|
|
|
+ .addParam("sc_code",sc_code)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(result, "data");
|
|
|
+ handleFeededData(dataArray);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ private void handleFeededData(JSONArray dataArray) {
|
|
|
+ MaintainitemBean bean;
|
|
|
+ mFeededList.clear();
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ bean= new MaintainitemBean(
|
|
|
+ data.getString("MM_PRODCODE"),
|
|
|
+ data.getString("PR_DETAIL"),
|
|
|
+ data.getString("PR_SPEC"));
|
|
|
+ mFeededList.add(bean);
|
|
|
+ }
|
|
|
+ setAdapter(mFeededList);
|
|
|
+ }
|
|
|
+ private void setAdapter(ArrayList<MaintainitemBean> mList) {
|
|
|
+ LogUtil.i("mList", JSON.toJSONString(mList));
|
|
|
+ myAdapter = new SelectAdapter(mList);
|
|
|
+ mRecyclerView.setAdapter(myAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存
|
|
|
+ */
|
|
|
+ private void getNewsave(String prods) {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_MODIFYMAPRODS)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("ma_code",ma_code)
|
|
|
+ .addParam("sc_code",sc_code)
|
|
|
+ .addParam("prods",prods)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String data = FastjsonUtil.getText(o.toString(), "data");
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, data.toString()+"");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (!hidden) {
|
|
|
+ setTitle("预加工报工");
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
+ } else {
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ super.onDestroyView();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("NonConstantResourceId")
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (resultCode != Activity.RESULT_OK) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ public class SelectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
+
|
|
|
+ private ArrayList<MaintainitemBean> mList = new ArrayList<>();
|
|
|
+ private SparseBooleanArray mSelectedPositions = new SparseBooleanArray();
|
|
|
+ private boolean mIsSelectable = false;
|
|
|
+
|
|
|
+
|
|
|
+ public SelectAdapter(ArrayList<MaintainitemBean> list) {
|
|
|
+ if (list == null) {
|
|
|
+ throw new IllegalArgumentException("model Data must not be null");
|
|
|
+ }
|
|
|
+ mList = list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新adpter的数据和选择状态
|
|
|
+ public void updateDataSet(ArrayList<MaintainitemBean> list) {
|
|
|
+ this.mList = list;
|
|
|
+ mSelectedPositions = new SparseBooleanArray();
|
|
|
+// ab.setTitle("已选择" + 0 + "项");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获得选中条目的结果
|
|
|
+ public ArrayList<MaintainitemBean> getSelectedItem() {
|
|
|
+ ArrayList<MaintainitemBean> selectList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < mList.size(); i++) {
|
|
|
+ if (isItemChecked(i)) {
|
|
|
+ selectList.add(mList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return selectList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
|
+ View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.recyclerview_item2, viewGroup, false);
|
|
|
+ return new ListItemViewHolder(itemView);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置给定位置条目的选择状态
|
|
|
+ private void setItemChecked(int position, boolean isChecked) {
|
|
|
+ mSelectedPositions.put(position, isChecked);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据位置判断条目是否选中
|
|
|
+ private boolean isItemChecked(int position) {
|
|
|
+ return mSelectedPositions.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据位置判断条目是否可选
|
|
|
+ private boolean isSelectable() {
|
|
|
+ return mIsSelectable;
|
|
|
+ }
|
|
|
+ //设置给定位置条目的可选与否的状态
|
|
|
+ private void setSelectable(boolean selectable) {
|
|
|
+ mIsSelectable = selectable;
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定界面,设置监听
|
|
|
+ @Override
|
|
|
+ public void onBindViewHolder(final RecyclerView.@NotNull ViewHolder holder, @SuppressLint("RecyclerView") int i) {
|
|
|
+ //设置条目状态
|
|
|
+ ((ListItemViewHolder) holder).tv_liaocode.setText("物料编号:"+mList.get(i).getMM_PRODCODE());
|
|
|
+ ((ListItemViewHolder) holder).tv_liaotetall.setText("物料名称:"+mList.get(i).getPR_DETAIL());
|
|
|
+ ((ListItemViewHolder) holder).tv_liaospec.setText("物料规格:"+mList.get(i).getPR_SPEC());
|
|
|
+
|
|
|
+
|
|
|
+ ((ListItemViewHolder) holder).checkBox.setChecked(isItemChecked(i));
|
|
|
+// if (i%2==0){
|
|
|
+// ((ListItemViewHolder) holder).line_color.setBackgroundColor(getResources().getColor(R.color.button_normal));
|
|
|
+// }else {
|
|
|
+// ((ListItemViewHolder) holder).line_color.setBackgroundColor(Color.WHITE);
|
|
|
+// }
|
|
|
+ //checkBox的监听
|
|
|
+ ((ListItemViewHolder) holder).checkBox.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (isItemChecked(i)) {
|
|
|
+ setItemChecked(i, false);
|
|
|
+ } else {
|
|
|
+ setItemChecked(i, true);
|
|
|
+ }
|
|
|
+// for (int i2=0;i2<mList.size();i2++){
|
|
|
+// setItemChecked(i2, true);
|
|
|
+// }
|
|
|
+
|
|
|
+// ab.setTitle("已选择" + getSelectedItem().size() + "项");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //条目view的监听
|
|
|
+ ((ListItemViewHolder) holder).itemView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (isItemChecked(i)) {
|
|
|
+ setItemChecked(i, false);
|
|
|
+ } else {
|
|
|
+ setItemChecked(i, true);
|
|
|
+ }
|
|
|
+// notifyItemChanged(i);
|
|
|
+// if (!StringUtil.isEmpty(mList.get(i).getDI_REMARK())){
|
|
|
+// ((ListItemViewHolder) holder).tv_remark.setText("点检值:"+mList.get(i).getDI_REMARK());
|
|
|
+// }
|
|
|
+
|
|
|
+// ab.setTitle("已选择" + getSelectedItem().size() + "项");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return mList == null ? 0 : mList.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ListItemViewHolder extends RecyclerView.ViewHolder{
|
|
|
+ //ViewHolder
|
|
|
+ CheckBox checkBox;
|
|
|
+ TextView tv_liaocode;
|
|
|
+ TextView tv_liaotetall;
|
|
|
+ TextView tv_liaospec;
|
|
|
+ ListItemViewHolder(View view) {
|
|
|
+ super(view);
|
|
|
+ this.tv_liaocode = (TextView) view.findViewById(R.id.tv_liaocode);
|
|
|
+ this.tv_liaotetall = (TextView) view.findViewById(R.id.tv_liaotetall);
|
|
|
+ this.tv_liaospec = (TextView) view.findViewById(R.id.tv_liaospec);
|
|
|
+ this.checkBox = (CheckBox) view.findViewById(R.id.select_checkbox);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|