Commit 89d4cbf3 by lihuaikun

fix:修改接口格式 增加了一个第三方接入接口

parent 032e6d86
package cn.dankal.yunlaboratory.ui.activity; package cn.dankal.yunlaboratory.ui.activity;
import android.content.Intent; import android.content.Intent;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
...@@ -9,6 +10,7 @@ import butterknife.OnClick; ...@@ -9,6 +10,7 @@ import butterknife.OnClick;
import cn.dankal.basiclib.DKUserManager; import cn.dankal.basiclib.DKUserManager;
import cn.dankal.basiclib.base.activity.BaseActivity; import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.base.mvp.BasePresenter; import cn.dankal.basiclib.base.mvp.BasePresenter;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitRecordModel; import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.UserModel; import cn.dankal.basiclib.model.UserModel;
import cn.dankal.basiclib.util.GlideUtils; import cn.dankal.basiclib.util.GlideUtils;
...@@ -32,6 +34,8 @@ public class GetSampleActivity extends BaseActivity { ...@@ -32,6 +34,8 @@ public class GetSampleActivity extends BaseActivity {
private SubmitRecordModel recordModel; private SubmitRecordModel recordModel;
@Override @Override
public BasePresenter createPresenter() { public BasePresenter createPresenter() {
return null; return null;
...@@ -47,6 +51,10 @@ public class GetSampleActivity extends BaseActivity { ...@@ -47,6 +51,10 @@ public class GetSampleActivity extends BaseActivity {
recordModel= (SubmitRecordModel) getIntent().getSerializableExtra("data"); recordModel= (SubmitRecordModel) getIntent().getSerializableExtra("data");
tvTitle.setText("取回样本"); tvTitle.setText("取回样本");
tvChoose.setEnabled(true); tvChoose.setEnabled(true);
initView(); initView();
...@@ -73,6 +81,7 @@ public class GetSampleActivity extends BaseActivity { ...@@ -73,6 +81,7 @@ public class GetSampleActivity extends BaseActivity {
case R.id.tv_choose: case R.id.tv_choose:
Intent intent=new Intent(this,StartTestActivity.class); Intent intent=new Intent(this,StartTestActivity.class);
intent.putExtra("data",recordModel); intent.putExtra("data",recordModel);
startActivity(intent); startActivity(intent);
finish(); finish();
break; break;
......
package cn.dankal.yunlaboratory.ui.activity; package cn.dankal.yunlaboratory.ui.activity;
import android.content.Intent; import android.content.Intent;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
...@@ -9,10 +10,12 @@ import java.util.List; ...@@ -9,10 +10,12 @@ import java.util.List;
import api.UserServiceFactory; import api.UserServiceFactory;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import cn.dankal.basiclib.DKUserManager;
import cn.dankal.basiclib.base.activity.BaseActivity; import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.base.mvp.BasePresenter; import cn.dankal.basiclib.base.mvp.BasePresenter;
import cn.dankal.basiclib.model.BaseModel; import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.ProjectModel; import cn.dankal.basiclib.model.ProjectModel;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitRecordModel; import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.SubmitResultBody; import cn.dankal.basiclib.model.SubmitResultBody;
import cn.dankal.basiclib.rx.MapFunc; import cn.dankal.basiclib.rx.MapFunc;
...@@ -42,7 +45,7 @@ public class StartTestActivity extends BaseActivity { ...@@ -42,7 +45,7 @@ public class StartTestActivity extends BaseActivity {
private int deviceId=-1; private int deviceId=-1;
private SubmitResultBody submitResultBody; private SubmitResultBody submitResultBody;
private SampleRecordBody sampleRecordBody;
@Override @Override
public BasePresenter createPresenter() { public BasePresenter createPresenter() {
return null; return null;
...@@ -66,6 +69,16 @@ public class StartTestActivity extends BaseActivity { ...@@ -66,6 +69,16 @@ public class StartTestActivity extends BaseActivity {
getProjectList(); getProjectList();
getDeviceList(); getDeviceList();
sampleRecordBody=new SampleRecordBody();
if (!TextUtils.isEmpty(recordModel.getSample_num())){
sampleRecordBody.setSample_num(recordModel.getSample_num());
sampleRecordBody.setSample_name(recordModel.getSample_name());
sampleRecordBody.setSend_user(recordModel.getSend_user());
sampleRecordBody.setGet_user(recordModel.getGet_user());
sampleRecordBody.setGet_time(recordModel.getCreated_at());
sampleRecordBody.setTest_user(DKUserManager.getUserInfo().getName());
}
chooseProjectDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() { chooseProjectDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() {
@Override @Override
...@@ -76,6 +89,7 @@ public class StartTestActivity extends BaseActivity { ...@@ -76,6 +89,7 @@ public class StartTestActivity extends BaseActivity {
if (projectModels!=null&&pos<projectModels.size()){ if (projectModels!=null&&pos<projectModels.size()){
tvProjectName.setText(projectModels.get(pos).getName()); tvProjectName.setText(projectModels.get(pos).getName());
projectId=projectModels.get(pos).getId(); projectId=projectModels.get(pos).getId();
sampleRecordBody.setProject_name(projectModels.get(pos).getName());
} }
} }
}); });
...@@ -87,6 +101,10 @@ public class StartTestActivity extends BaseActivity { ...@@ -87,6 +101,10 @@ public class StartTestActivity extends BaseActivity {
int pos = chooseDeviceDialog.getCurrentItem(); int pos = chooseDeviceDialog.getCurrentItem();
if (deviceModels!=null&&pos<deviceModels.size()){ if (deviceModels!=null&&pos<deviceModels.size()){
sampleRecordBody.setDevice_name(deviceModels.get(pos).getName());
sampleRecordBody.setDevice_num(String.valueOf(deviceModels.get(pos).getId()));
tvMachineName.setText(deviceModels.get(pos).getName()); tvMachineName.setText(deviceModels.get(pos).getName());
deviceId=deviceModels.get(pos).getId(); deviceId=deviceModels.get(pos).getId();
} }
...@@ -120,6 +138,9 @@ public class StartTestActivity extends BaseActivity { ...@@ -120,6 +138,9 @@ public class StartTestActivity extends BaseActivity {
submitResultBody.setDevice_id(deviceId); submitResultBody.setDevice_id(deviceId);
Intent intent = new Intent(this, UploadResultActivity.class); Intent intent = new Intent(this, UploadResultActivity.class);
intent.putExtra("data",submitResultBody); intent.putExtra("data",submitResultBody);
if (!TextUtils.isEmpty(recordModel.getSample_num())){
intent.putExtra("data2",sampleRecordBody);
}
startActivity(intent); startActivity(intent);
finish(); finish();
break; break;
......
...@@ -5,18 +5,27 @@ import android.view.View; ...@@ -5,18 +5,27 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import api.UserServiceFactory; import api.UserServiceFactory;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import cn.dankal.basiclib.api.BaseApi;
import cn.dankal.basiclib.api.UserService;
import cn.dankal.basiclib.base.activity.BaseActivity; import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.base.mvp.BasePresenter; import cn.dankal.basiclib.base.mvp.BasePresenter;
import cn.dankal.basiclib.model.BaseModel; import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.ErrCodeModel;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitResultBody; import cn.dankal.basiclib.model.SubmitResultBody;
import cn.dankal.basiclib.rx.MapFunc; import cn.dankal.basiclib.rx.MapFunc;
import cn.dankal.basiclib.rx.NormalSubscriber; import cn.dankal.basiclib.rx.NormalSubscriber;
import cn.dankal.basiclib.util.TimeUtil;
import cn.dankal.yunlaboratory.R; import cn.dankal.yunlaboratory.R;
import cn.dankal.yunlaboratory.ui.widget.MainButton; import cn.dankal.yunlaboratory.ui.widget.MainButton;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class UploadResultActivity extends BaseActivity { public class UploadResultActivity extends BaseActivity {
@BindView(R.id.tv_title) @BindView(R.id.tv_title)
...@@ -28,6 +37,8 @@ public class UploadResultActivity extends BaseActivity { ...@@ -28,6 +37,8 @@ public class UploadResultActivity extends BaseActivity {
private SubmitResultBody body; private SubmitResultBody body;
private SampleRecordBody sampleRecordBody;
@Override @Override
public BasePresenter createPresenter() { public BasePresenter createPresenter() {
return null; return null;
...@@ -42,6 +53,11 @@ public class UploadResultActivity extends BaseActivity { ...@@ -42,6 +53,11 @@ public class UploadResultActivity extends BaseActivity {
protected void initComponents() { protected void initComponents() {
tvTitle.setText("结果录入"); tvTitle.setText("结果录入");
body = (SubmitResultBody) getIntent().getSerializableExtra("data"); body = (SubmitResultBody) getIntent().getSerializableExtra("data");
if (getIntent().hasExtra("data2")) {
sampleRecordBody = (SampleRecordBody) getIntent().getSerializableExtra("data2");
}
btnUpload.setEnabled(true); btnUpload.setEnabled(true);
} }
...@@ -53,9 +69,9 @@ public class UploadResultActivity extends BaseActivity { ...@@ -53,9 +69,9 @@ public class UploadResultActivity extends BaseActivity {
finish(); finish();
break; break;
case R.id.btn_upload: case R.id.btn_upload:
String report=etResult.getText().toString(); String report = etResult.getText().toString();
if (!TextUtils.isEmpty(report)){ if (!TextUtils.isEmpty(report)) {
body.setContent(report); body.setContent(report);
UserServiceFactory.submitReport(body).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel>() { UserServiceFactory.submitReport(body).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel>() {
...@@ -66,16 +82,51 @@ public class UploadResultActivity extends BaseActivity { ...@@ -66,16 +82,51 @@ public class UploadResultActivity extends BaseActivity {
@Override @Override
public void onNext(BaseModel stringBaseModel) { public void onNext(BaseModel stringBaseModel) {
if (sampleRecordBody != null) {
sampleRecordBody.setTest_time(TimeUtil.getTime(System.currentTimeMillis() / 1000, TimeUtil.DATEFORMATER));
BaseApi.getRetrofit(BaseApi.OTHER_BASE_URL).create(UserService.class).sendsamplerecord(sampleRecordBody)
.observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new NormalSubscriber<String>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(String s) {
ErrCodeModel model = JSON.parseObject(s, ErrCodeModel.class);
if (model.getErrcode() == 0) {
showToast("上传成功"); showToast("上传成功");
view.postDelayed(new Runnable() { view.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
finish(); finish();
} }
},1000); }, 1000);
} else {
showToast(model.getErrmsg());
}
}
});
} else {
showToast("上传成功");
view.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, 1000);
}
} }
}); });
}else {
//
} else {
showToast("请填写样本检测报告"); showToast("请填写样本检测报告");
} }
break; break;
......
...@@ -58,7 +58,8 @@ public class ScanFragment extends BaseFragment { ...@@ -58,7 +58,8 @@ public class ScanFragment extends BaseFragment {
getBackSampleDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() { getBackSampleDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
inputPersonNoDialog.dismiss(); getBackSampleDialog.dismiss();
inputPersonNoDialog.show();
} }
}); });
...@@ -69,7 +70,7 @@ public class ScanFragment extends BaseFragment { ...@@ -69,7 +70,7 @@ public class ScanFragment extends BaseFragment {
String nameStr = inputPersonNoDialog.getInputName(); String nameStr = inputPersonNoDialog.getInputName();
if (!TextUtils.isEmpty(nameStr)) { if (!TextUtils.isEmpty(nameStr)) {
inputPersonNoDialog.dismiss(); inputPersonNoDialog.dismiss();
UserServiceFactory.sampleNext(nameStr).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel<SubmitRecordModel>>() { UserServiceFactory.sampleNext(nameStr,codeResult).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel<SubmitRecordModel>>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
showLoadingDialog(); showLoadingDialog();
......
...@@ -28,6 +28,8 @@ public class BaseApi { ...@@ -28,6 +28,8 @@ public class BaseApi {
public static final String BASE_URL = isDev ? "http://tp.lzdu.com/api/" public static final String BASE_URL = isDev ? "http://tp.lzdu.com/api/"
: "http://tp.lzdu.com/api/"; : "http://tp.lzdu.com/api/";
public static final String OTHER_BASE_URL="http://gd21262648.imwork.net:30110/";
private static LinkedHashMap<String, Retrofit> linkedHashMap = new LinkedHashMap<>(3); private static LinkedHashMap<String, Retrofit> linkedHashMap = new LinkedHashMap<>(3);
......
...@@ -8,6 +8,7 @@ import cn.dankal.basiclib.model.BaseModel; ...@@ -8,6 +8,7 @@ import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.LoginModel; import cn.dankal.basiclib.model.LoginModel;
import cn.dankal.basiclib.model.ProjectModel; import cn.dankal.basiclib.model.ProjectModel;
import cn.dankal.basiclib.model.SampleModel; import cn.dankal.basiclib.model.SampleModel;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitRecordModel; import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.SubmitResultBody; import cn.dankal.basiclib.model.SubmitResultBody;
import cn.dankal.basiclib.model.UserInfoBody; import cn.dankal.basiclib.model.UserInfoBody;
...@@ -59,7 +60,7 @@ public interface UserService { ...@@ -59,7 +60,7 @@ public interface UserService {
*/ */
@POST("sample/next") @POST("sample/next")
@FormUrlEncoded @FormUrlEncoded
Observable<BaseModel<SubmitRecordModel>> sampleNext(@Field("ss_name") String ss_name); Observable<BaseModel<SubmitRecordModel>> sampleNext(@Field("ss_name") String ss_name,@Field("sample_num") String sample_num);
/** /**
* 获取项目 * 获取项目
...@@ -132,11 +133,11 @@ public interface UserService { ...@@ -132,11 +133,11 @@ public interface UserService {
/** /**
* 退出登录 *
* *
* @return * @return
*/ */
@GET("app/User/logout") @POST("api/sendsamplerecord")
Observable<String> logout(); Observable<String> sendsamplerecord(@Body SampleRecordBody body);
} }
package cn.dankal.basiclib.model;
public class ErrCodeModel {
private int errcode;
private String errmsg;
public int getErrcode() {
return errcode;
}
public void setErrcode(int errcode) {
this.errcode = errcode;
}
public String getErrmsg() {
return errmsg;
}
public void setErrmsg(String errmsg) {
this.errmsg = errmsg;
}
}
...@@ -10,6 +10,8 @@ public class ProjectModel { ...@@ -10,6 +10,8 @@ public class ProjectModel {
private int id; private int id;
private String name; private String name;
// 该字段只在设备列表中存在
private String device_num;
public int getId() { public int getId() {
return id; return id;
...@@ -26,4 +28,12 @@ public class ProjectModel { ...@@ -26,4 +28,12 @@ public class ProjectModel {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getDevice_num() {
return device_num;
}
public void setDevice_num(String device_num) {
this.device_num = device_num;
}
} }
package cn.dankal.basiclib.model;
import java.io.Serializable;
public class SampleRecordBody implements Serializable {
private String sample_num;
private String sample_name;
private String device_name;
private String device_num;
private String project_name;
private String test_user;
private String test_time;
private String send_user;
private String get_user;
private String get_time;
public String getSample_num() {
return sample_num;
}
public void setSample_num(String sample_num) {
this.sample_num = sample_num;
}
public String getSample_name() {
return sample_name;
}
public void setSample_name(String sample_name) {
this.sample_name = sample_name;
}
public String getDevice_name() {
return device_name;
}
public void setDevice_name(String device_name) {
this.device_name = device_name;
}
public String getDevice_num() {
return device_num;
}
public void setDevice_num(String device_num) {
this.device_num = device_num;
}
public String getProject_name() {
return project_name;
}
public void setProject_name(String project_name) {
this.project_name = project_name;
}
public String getTest_user() {
return test_user;
}
public void setTest_user(String test_user) {
this.test_user = test_user;
}
public String getTest_time() {
return test_time;
}
public void setTest_time(String test_time) {
this.test_time = test_time;
}
public String getSend_user() {
return send_user;
}
public void setSend_user(String send_user) {
this.send_user = send_user;
}
public String getGet_user() {
return get_user;
}
public void setGet_user(String get_user) {
this.get_user = get_user;
}
public String getGet_time() {
return get_time;
}
public void setGet_time(String get_time) {
this.get_time = get_time;
}
}
...@@ -7,6 +7,10 @@ public class SubmitRecordModel implements Serializable { ...@@ -7,6 +7,10 @@ public class SubmitRecordModel implements Serializable {
// "created_at": "2020-06-14 08:55:23" // 取样时间 // "created_at": "2020-06-14 08:55:23" // 取样时间
private int id; private int id;
private String created_at; private String created_at;
private String get_user;
private String send_user;
private String sample_num;
private String sample_name;
public int getId() { public int getId() {
return id; return id;
...@@ -23,4 +27,36 @@ public class SubmitRecordModel implements Serializable { ...@@ -23,4 +27,36 @@ public class SubmitRecordModel implements Serializable {
public void setCreated_at(String created_at) { public void setCreated_at(String created_at) {
this.created_at = created_at; this.created_at = created_at;
} }
public String getGet_user() {
return get_user;
}
public void setGet_user(String get_user) {
this.get_user = get_user;
}
public String getSend_user() {
return send_user;
}
public void setSend_user(String send_user) {
this.send_user = send_user;
}
public String getSample_num() {
return sample_num;
}
public void setSample_num(String sample_num) {
this.sample_num = sample_num;
}
public String getSample_name() {
return sample_name;
}
public void setSample_name(String sample_name) {
this.sample_name = sample_name;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment