Commit 89d4cbf3 by lihuaikun

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

parent 032e6d86
package cn.dankal.yunlaboratory.ui.activity;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
......@@ -9,6 +10,7 @@ import butterknife.OnClick;
import cn.dankal.basiclib.DKUserManager;
import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.base.mvp.BasePresenter;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.UserModel;
import cn.dankal.basiclib.util.GlideUtils;
......@@ -32,6 +34,8 @@ public class GetSampleActivity extends BaseActivity {
private SubmitRecordModel recordModel;
@Override
public BasePresenter createPresenter() {
return null;
......@@ -47,6 +51,10 @@ public class GetSampleActivity extends BaseActivity {
recordModel= (SubmitRecordModel) getIntent().getSerializableExtra("data");
tvTitle.setText("取回样本");
tvChoose.setEnabled(true);
initView();
......@@ -73,6 +81,7 @@ public class GetSampleActivity extends BaseActivity {
case R.id.tv_choose:
Intent intent=new Intent(this,StartTestActivity.class);
intent.putExtra("data",recordModel);
startActivity(intent);
finish();
break;
......
package cn.dankal.yunlaboratory.ui.activity;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
......@@ -9,10 +10,12 @@ import java.util.List;
import api.UserServiceFactory;
import butterknife.BindView;
import butterknife.OnClick;
import cn.dankal.basiclib.DKUserManager;
import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.base.mvp.BasePresenter;
import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.ProjectModel;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.SubmitResultBody;
import cn.dankal.basiclib.rx.MapFunc;
......@@ -42,7 +45,7 @@ public class StartTestActivity extends BaseActivity {
private int deviceId=-1;
private SubmitResultBody submitResultBody;
private SampleRecordBody sampleRecordBody;
@Override
public BasePresenter createPresenter() {
return null;
......@@ -66,6 +69,16 @@ public class StartTestActivity extends BaseActivity {
getProjectList();
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() {
@Override
......@@ -76,6 +89,7 @@ public class StartTestActivity extends BaseActivity {
if (projectModels!=null&&pos<projectModels.size()){
tvProjectName.setText(projectModels.get(pos).getName());
projectId=projectModels.get(pos).getId();
sampleRecordBody.setProject_name(projectModels.get(pos).getName());
}
}
});
......@@ -87,6 +101,10 @@ public class StartTestActivity extends BaseActivity {
int pos = chooseDeviceDialog.getCurrentItem();
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());
deviceId=deviceModels.get(pos).getId();
}
......@@ -120,6 +138,9 @@ public class StartTestActivity extends BaseActivity {
submitResultBody.setDevice_id(deviceId);
Intent intent = new Intent(this, UploadResultActivity.class);
intent.putExtra("data",submitResultBody);
if (!TextUtils.isEmpty(recordModel.getSample_num())){
intent.putExtra("data2",sampleRecordBody);
}
startActivity(intent);
finish();
break;
......
......@@ -5,18 +5,27 @@ import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import api.UserServiceFactory;
import butterknife.BindView;
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.mvp.BasePresenter;
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.rx.MapFunc;
import cn.dankal.basiclib.rx.NormalSubscriber;
import cn.dankal.basiclib.util.TimeUtil;
import cn.dankal.yunlaboratory.R;
import cn.dankal.yunlaboratory.ui.widget.MainButton;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class UploadResultActivity extends BaseActivity {
@BindView(R.id.tv_title)
......@@ -28,6 +37,8 @@ public class UploadResultActivity extends BaseActivity {
private SubmitResultBody body;
private SampleRecordBody sampleRecordBody;
@Override
public BasePresenter createPresenter() {
return null;
......@@ -42,6 +53,11 @@ public class UploadResultActivity extends BaseActivity {
protected void initComponents() {
tvTitle.setText("结果录入");
body = (SubmitResultBody) getIntent().getSerializableExtra("data");
if (getIntent().hasExtra("data2")) {
sampleRecordBody = (SampleRecordBody) getIntent().getSerializableExtra("data2");
}
btnUpload.setEnabled(true);
}
......@@ -53,9 +69,9 @@ public class UploadResultActivity extends BaseActivity {
finish();
break;
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);
UserServiceFactory.submitReport(body).map(new MapFunc<>()).subscribe(new NormalSubscriber<BaseModel>() {
......@@ -66,16 +82,51 @@ public class UploadResultActivity extends BaseActivity {
@Override
public void onNext(BaseModel stringBaseModel) {
showToast("上传成功");
view.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
},1000);
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("上传成功");
view.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, 1000);
} else {
showToast(model.getErrmsg());
}
}
});
} else {
showToast("上传成功");
view.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, 1000);
}
}
});
}else {
//
} else {
showToast("请填写样本检测报告");
}
break;
......
......@@ -58,7 +58,8 @@ public class ScanFragment extends BaseFragment {
getBackSampleDialog.setViewClick(R.id.tv_positive, new View.OnClickListener() {
@Override
public void onClick(View v) {
inputPersonNoDialog.dismiss();
getBackSampleDialog.dismiss();
inputPersonNoDialog.show();
}
});
......@@ -69,7 +70,7 @@ public class ScanFragment extends BaseFragment {
String nameStr = inputPersonNoDialog.getInputName();
if (!TextUtils.isEmpty(nameStr)) {
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
public void onSubscribe(Disposable d) {
showLoadingDialog();
......
......@@ -28,6 +28,8 @@ public class BaseApi {
public static final String BASE_URL = isDev ? "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);
......
......@@ -8,6 +8,7 @@ import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.LoginModel;
import cn.dankal.basiclib.model.ProjectModel;
import cn.dankal.basiclib.model.SampleModel;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.SubmitResultBody;
import cn.dankal.basiclib.model.UserInfoBody;
......@@ -59,7 +60,7 @@ public interface UserService {
*/
@POST("sample/next")
@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 {
/**
* 退出登录
*
*
* @return
*/
@GET("app/User/logout")
Observable<String> logout();
@POST("api/sendsamplerecord")
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 {
private int id;
private String name;
// 该字段只在设备列表中存在
private String device_num;
public int getId() {
return id;
......@@ -26,4 +28,12 @@ public class ProjectModel {
public void setName(String 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 {
// "created_at": "2020-06-14 08:55:23" // 取样时间
private int id;
private String created_at;
private String get_user;
private String send_user;
private String sample_num;
private String sample_name;
public int getId() {
return id;
......@@ -23,4 +27,36 @@ public class SubmitRecordModel implements Serializable {
public void setCreated_at(String 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