|
|
|
@ -10,6 +10,9 @@ import android.widget.Toast;
|
|
|
|
import com.rehome.bhdxj.DBModel.Djjh;
|
|
|
|
import com.rehome.bhdxj.DBModel.Djjh;
|
|
|
|
import com.rehome.bhdxj.DBModel.QYDDATABean;
|
|
|
|
import com.rehome.bhdxj.DBModel.QYDDATABean;
|
|
|
|
import com.rehome.bhdxj.DBModel.XDJJHXZDataBean;
|
|
|
|
import com.rehome.bhdxj.DBModel.XDJJHXZDataBean;
|
|
|
|
|
|
|
|
import com.rehome.bhdxj.DBModel.XSJJHDataBean;
|
|
|
|
|
|
|
|
import com.rehome.bhdxj.DBModel.XSJJHXZDataBean;
|
|
|
|
|
|
|
|
import com.rehome.bhdxj.DBModel.Xjjh;
|
|
|
|
import com.rehome.bhdxj.R;
|
|
|
|
import com.rehome.bhdxj.R;
|
|
|
|
import com.rehome.bhdxj.adapter.ScjhAdapter;
|
|
|
|
import com.rehome.bhdxj.adapter.ScjhAdapter;
|
|
|
|
import com.rehome.bhdxj.base.BaseFragment;
|
|
|
|
import com.rehome.bhdxj.base.BaseFragment;
|
|
|
|
@ -47,6 +50,8 @@ public class DjdscFragment extends BaseFragment {
|
|
|
|
Button btn_del;
|
|
|
|
Button btn_del;
|
|
|
|
TextView tvNodata;
|
|
|
|
TextView tvNodata;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int uploadCecked = 0;
|
|
|
|
|
|
|
|
static int uploadSuccess = 0;
|
|
|
|
|
|
|
|
|
|
|
|
private View headView;
|
|
|
|
private View headView;
|
|
|
|
private View head;
|
|
|
|
private View head;
|
|
|
|
@ -191,15 +196,25 @@ public class DjdscFragment extends BaseFragment {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void uploadData() {
|
|
|
|
private void uploadData() {
|
|
|
|
|
|
|
|
uploadCecked = 0;
|
|
|
|
|
|
|
|
uploadSuccess = 0;
|
|
|
|
String USERNAME = (String) SPUtils.get(context, Contans.USERID, "");
|
|
|
|
String USERNAME = (String) SPUtils.get(context, Contans.USERID, "");
|
|
|
|
ScdjjhBean scdjjhbean = new ScdjjhBean();
|
|
|
|
|
|
|
|
scdjjhbean.setAction("DJ_GWSC_SET");
|
|
|
|
|
|
|
|
scdjjhbean.setYHID(USERNAME);
|
|
|
|
|
|
|
|
List<ScdjjhBean.DJ_DATA> djDataList = new ArrayList<>();
|
|
|
|
|
|
|
|
List<ScdjjhBean.DJ_DATA.QYDJ_DATA> qydjDataList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (int i = 0; i < xdjjhxzDataList.size(); i++) {
|
|
|
|
for (int i = 0; i < xdjjhxzDataList.size(); i++) {
|
|
|
|
ScdjjhBean.DJ_DATA dhdata = new ScdjjhBean.DJ_DATA();
|
|
|
|
|
|
|
|
if (xdjjhxzDataList.get(i).isChecked()) {
|
|
|
|
if (xdjjhxzDataList.get(i).isChecked()) {
|
|
|
|
|
|
|
|
uploadCecked++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < xdjjhxzDataList.size(); i++) {
|
|
|
|
|
|
|
|
if (xdjjhxzDataList.get(i).isChecked()) {
|
|
|
|
|
|
|
|
ScdjjhBean scdjjhbean = new ScdjjhBean();
|
|
|
|
|
|
|
|
scdjjhbean.setAction("DJ_GWSC_SET");
|
|
|
|
|
|
|
|
scdjjhbean.setYHID(USERNAME);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ScdjjhBean.DJ_DATA> djDataList = new ArrayList<>();
|
|
|
|
|
|
|
|
List<ScdjjhBean.DJ_DATA.QYDJ_DATA> qydjDataList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScdjjhBean.DJ_DATA dhdata = new ScdjjhBean.DJ_DATA();
|
|
|
|
|
|
|
|
|
|
|
|
final List<QYDDATABean> qyddataBeanList = qydDataBeanMap.get(xdjjhxzDataList.get(i).getGWID());
|
|
|
|
final List<QYDDATABean> qyddataBeanList = qydDataBeanMap.get(xdjjhxzDataList.get(i).getGWID());
|
|
|
|
scdjjhbean.setGWID(xdjjhxzDataList.get(i).getGWID());
|
|
|
|
scdjjhbean.setGWID(xdjjhxzDataList.get(i).getGWID());
|
|
|
|
scdjjhbean.setGWMC(xdjjhxzDataList.get(i).getGWMC());
|
|
|
|
scdjjhbean.setGWMC(xdjjhxzDataList.get(i).getGWMC());
|
|
|
|
@ -242,61 +257,77 @@ public class DjdscFragment extends BaseFragment {
|
|
|
|
sCData(json);
|
|
|
|
sCData(json);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void sCData(String json) {
|
|
|
|
private void sCData(String json) {
|
|
|
|
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.DJJHSC, RequestMethod.POST);
|
|
|
|
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.DJJHSC, RequestMethod.POST);
|
|
|
|
request.setDefineRequestBodyForJson(json);
|
|
|
|
request.setDefineRequestBodyForJson(json);
|
|
|
|
queue.add(1, request, new HttpResponseListener<>(getActivity(), request, callback, false, true, "上传数据中...请稍等..."));
|
|
|
|
queue.add(1, request, new HttpResponseListener<>(getActivity(), request, new HttpListener<String>() {
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
private HttpListener<String> callback = new HttpListener<String>() {
|
|
|
|
public void onSucceed(int what, Response<String> response) {
|
|
|
|
@Override
|
|
|
|
StatusInfo2 info = GsonUtils.GsonToBean(response.get(), StatusInfo2.class);
|
|
|
|
public void onSucceed(int what, Response<String> response) {
|
|
|
|
uploadSuccess++;
|
|
|
|
StatusInfo2 info = GsonUtils.GsonToBean(response.get(), StatusInfo2.class);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (what == 1) {
|
|
|
|
if (what == 1) {
|
|
|
|
if (info.getState() == 1) {
|
|
|
|
if (info.getState() == 1) {
|
|
|
|
if(uploadCecked == uploadSuccess){
|
|
|
|
for (int i = 0; i < xdjjhxzDataList.size(); i++) {
|
|
|
|
xdjjhxzDataList.removeIf((item) -> {
|
|
|
|
if (xdjjhxzDataList.get(i).isChecked()) {
|
|
|
|
if (item.isChecked()) {
|
|
|
|
DataSupport.deleteAll(XDJJHXZDataBean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
DataSupport.deleteAll(XDJJHXZDataBean.class, "GWID = ?", item.getGWID());
|
|
|
|
DataSupport.deleteAll(QYDDATABean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
DataSupport.deleteAll(QYDDATABean.class, "GWID = ?", item.getGWID());
|
|
|
|
DataSupport.deleteAll(Djjh.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
DataSupport.deleteAll(Djjh.class, "GWID = ?", item.getGWID());
|
|
|
|
xdjjhxzDataList.remove(xdjjhxzDataList.get(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return item.isChecked();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < xdjjhxzDataList.size(); i++) {
|
|
|
|
|
|
|
|
// if (xdjjhxzDataList.get(i).isChecked()) {
|
|
|
|
|
|
|
|
// DataSupport.deleteAll(XDJJHXZDataBean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
|
|
|
|
// DataSupport.deleteAll(QYDDATABean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
|
|
|
|
// DataSupport.deleteAll(Djjh.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
|
|
|
|
// xdjjhxzDataList.remove(xdjjhxzDataList.get(i));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
showToast(info.getMsg());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
showToast(info.getMsg());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
showToast(UiUtlis.getString(context, R.string.data_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
showToast(UiUtlis.getString(context, R.string.data_error));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onFailed(int what, Response<String> response) {
|
|
|
|
public void onFailed(int what, Response<String> response) {
|
|
|
|
|
|
|
|
uploadSuccess++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, false, true, "上传数据中...请稍等..."));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
private void deleteData() {
|
|
|
|
private void deleteData() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
|
|
builder.setTitle("提示");
|
|
|
|
builder.setTitle("提示");
|
|
|
|
builder.setTitle("你确定要删除?");
|
|
|
|
builder.setTitle("你确定要删除?");
|
|
|
|
builder.setNegativeButton("取消", (dialog, which) -> dialog.dismiss());
|
|
|
|
builder.setNegativeButton("取消", (dialog, which) -> dialog.dismiss());
|
|
|
|
builder.setPositiveButton("确定", (dialog, which) -> {
|
|
|
|
builder.setPositiveButton("确定", (dialog, which) -> {
|
|
|
|
for (int i = 0; i < xdjjhxzDataList.size(); i++) {
|
|
|
|
xdjjhxzDataList.removeIf((item) -> {
|
|
|
|
if (xdjjhxzDataList.get(i).isChecked()) {
|
|
|
|
if (item.isChecked()) {
|
|
|
|
DataSupport.deleteAll(XDJJHXZDataBean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
DataSupport.deleteAll(XDJJHXZDataBean.class, "GWID = ?", item.getGWID());
|
|
|
|
DataSupport.deleteAll(QYDDATABean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
DataSupport.deleteAll(QYDDATABean.class, "GWID = ?", item.getGWID());
|
|
|
|
DataSupport.deleteAll(Djjh.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
DataSupport.deleteAll(Djjh.class, "GWID = ?", item.getGWID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return item.isChecked();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// for (int i = 0; i < xdjjhxzDataList.size(); i++) {
|
|
|
|
|
|
|
|
// if (xdjjhxzDataList.get(i).isChecked()) {
|
|
|
|
|
|
|
|
// DataSupport.deleteAll(XDJJHXZDataBean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
|
|
|
|
// DataSupport.deleteAll(QYDDATABean.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
|
|
|
|
// DataSupport.deleteAll(Djjh.class, "GWID = ?", xdjjhxzDataList.get(i).getGWID());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
getDataInSQL();
|
|
|
|
getDataInSQL();
|
|
|
|
if (adapter != null) {
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|