缺陷工单页面和接口开发全部完成

master
hwf452 9 months ago
parent e403dea3b7
commit 2dff722602

@ -1,6 +1,8 @@
package com.rehome.bhdxj.activity
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.text.TextUtils
import android.view.View
import androidx.activity.result.ActivityResultLauncher
@ -15,6 +17,7 @@ import com.rehome.bhdxj.utils.HttpListener
import com.rehome.bhdxj.utils.NohttpUtils
import com.rehome.bhdxj.utils.RSAUtils
import com.rehome.bhdxj.utils.SPUtils
import com.rehome.bhdxj.weight.ConfirmDialog
import com.rehome.bhdxj.weight.ListDialog
import com.yolanda.nohttp.NoHttp
import com.yolanda.nohttp.RequestMethod
@ -45,24 +48,49 @@ class QxgdNewActivity : BaseActivityOaToolbarViewBinding<ActivityQxgdNewBinding>
private val gzxxDialogDatas: MutableList<String> = mutableListOf()
private var jzValue: String? = null
private var zyValue: kotlin.String? = null
private var lxvalue: kotlin.String? = null
private var qxdjValue: kotlin.String? = null
private var zyValue: String? = null
private var lxvalue: String? = null
private var qxdjValue: String? = null
private var wzbmValue: String? = null
private var deviceValue: kotlin.String? = null
private var deviceValue: String? = null
private var gzlbValue: String? = null
private var gzxxValue: kotlin.String? = null
private var gzxxValue: String? = null
override fun getViewBinding() = ActivityQxgdNewBinding.inflate(layoutInflater)
override fun getToolbar() = binding.toolbarView.toolbar
override fun initView() {
initToolbar("缺陷工单提交", "提交") {
if(checkCanSubmit()){
val builder = android.app.AlertDialog.Builder(context)
builder.setMessage("您确定要提交缺陷工单吗?")
builder.setTitle("提示")
builder.setPositiveButton(
"确定"
) { dialog, _ ->
dialog.dismiss()
checkConnectServerSubmitQx()
}
builder.setNegativeButton(
"取消"
) { dialog, _ -> dialog.dismiss()}
val dialog = builder.create()
dialog.show()
//确定按钮
val btnPos = dialog.getButton(DialogInterface.BUTTON_POSITIVE)
//取消按钮
val btnNeg = dialog.getButton(DialogInterface.BUTTON_NEGATIVE)
btnPos.setTextColor(Color.BLACK)
btnNeg.setTextColor(Color.BLACK)
}
}
launcherResultWz = createWzActivityResultLauncher()
queueNoHttp = NoHttp.newRequestQueue(1)
val userIdTemp = SPUtils.get(this, Contans.USERID, "") as String
@ -226,6 +254,56 @@ class QxgdNewActivity : BaseActivityOaToolbarViewBinding<ActivityQxgdNewBinding>
}
}
private fun checkCanSubmit():Boolean {
// private var jzValue: String? = null
// private var zyValue: String? = null
// private var lxvalue: String? = null
// private var qxdjValue: String? = null
//
// private var wzbmValue: String? = null
// private var deviceValue: String? = null
// private var gzlbValue: String? = null
// private var gzxxValue: String? = null
if(TextUtils.isEmpty(jzValue)){
showToast("请选择机组")
return false
}
if(TextUtils.isEmpty(zyValue)){
showToast("请选择专业")
return false
}
if(TextUtils.isEmpty(lxvalue)){
showToast("请选择工作类型")
return false
}
if(TextUtils.isEmpty(qxdjValue)){
showToast("请选择工单级别")
return false
}
if(TextUtils.isEmpty(wzbmValue)){
showToast("请选择位置")
return false
}
if(TextUtils.isEmpty(deviceValue)){
showToast("请选择设备")
return false
}
if(TextUtils.isEmpty(gzlbValue)){
showToast("请选择故障类别")
return false
}
if(TextUtils.isEmpty(gzxxValue)){
showToast("请选故障现象")
return false
}
if(TextUtils.isEmpty(binding.etQxms.contentText.toString().trim())){
showToast("缺陷描述必填")
return false
}
return true
}
private fun getDropDown(type:String) {
var param = HashMap<String,String>()
if(type=="jz"){
@ -496,4 +574,89 @@ class QxgdNewActivity : BaseActivityOaToolbarViewBinding<ActivityQxgdNewBinding>
}
}, true, true, "连接服务器...")
}
private fun checkConnectServerSubmitQx() {
var param = HashMap<String,String>()
val json = GsonUtils.GsonString(param)
val url = Contans.MAXIMOIP + Contans.check_server_connect
showLog(url)
showLog(json)
val request = NoHttp.createStringRequest(
url,
RequestMethod.POST
)
request.setDefineRequestBodyForJson(json)
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) {
val result = response?.get()
if (result != null) {
showLog("-----checkConnectServer onSucceed----")
showLog(result)
if(result == "1"){
showLog("connect server success")
//提交缺陷工单
submitQx()
}else{
showToast("无法连接到服务器,请检查网络环境")
}
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
showLog("connect server onFailed")
showToast("无法连接到服务器,请检查网络环境")
}
}, true, true, "连接服务器...")
}
private fun submitQx() {
val param = HashMap<String,String>()
//故障类别
param["action"] = "QXGD_WORKORDER_Add" //
param["description"] = binding.etQxms.contentText.toString().trim() //描述
param["reportedby"] = username //工号
param["location"] = wzbmValue?:"" //位置
param["assetnum"] = deviceValue?:"" //设备
param["worktype"] = lxvalue?:"" //工作类型
param["udgddj"] = qxdjValue?:"" //工单级别
param["wolo2"] = jzValue?:"" //机组
param["crewid"] = zyValue?:"" //专业
param["udfailurecode"] = gzlbValue?:"" //故障类别
param["udfailureproblem"] = gzxxValue?:"" //故障现象
val json = GsonUtils.GsonString(param)
val url = Contans.MAXIMOIP + Contans.QX_SUBMIT_URL
showLog(url)
showLog(json)
val request = NoHttp.createStringRequest(
url,
RequestMethod.POST
)
request.setDefineRequestBodyForJson(json)
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) {
val result = response?.get()
showLog(result)
val bean = GsonUtils.GsonToBean(
result,
ZyNewBean::class.java
)
if (bean != null && bean.state == 1) {
//提交成功
val confirmDialog = ConfirmDialog(
context, "缺陷工单提交成功"
) { finish() }
confirmDialog.setTvTitle("提示")
confirmDialog.setCancelable(true)
confirmDialog.show()
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
showLog("connect server onFailed")
showToast("无法连接到服务器,请检查网络环境")
}
}, true, true, "连接服务器...")
}
}

@ -1,6 +1,9 @@
package com.rehome.bhdxj.activity
import android.app.AlertDialog
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.text.TextUtils
import android.view.View

@ -26,8 +26,8 @@ public class Contans {
//缺陷工单专业下拉
public static String QX_GET_ZY_DROP = "QXGD/QXGD_JCSJ.ashx";
//缺陷工单位置查询
public static String QX_GET_ZW_SEARCH = "QXGD/QXGD_JCSJ.ashx";
//缺陷工单提交
public static String QX_SUBMIT_URL= "QXGD/QXGD_WORKORDER.ashx";
//连接服务器测试看客户端是否能连接到服务器如果能就响应个1
public static final String check_server_connect = "WL/WLPD.ashx";

@ -0,0 +1,99 @@
package com.rehome.bhdxj.weight;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import com.rehome.bhdxj.databinding.DialogConfirmBinding;
/**
* Create By HuangWenFei
* 2023-01-12 11:55
*
*/
public class ConfirmDialog extends Dialog {
protected Context context;
protected View mView;
protected DialogConfirmBinding binding;
protected ConfirmDialogListener listener;
protected String msg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(mView);
Window window = getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = (getScreenWidth(context)) * 2 / 3;
window.setGravity(Gravity.CENTER);
setTvMsg(msg);
binding.bottomBtnView.dialogCommit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
if (listener != null) {
listener.confirm();
}
}
});
}
public ConfirmDialog(@NonNull Context context, String msg, ConfirmDialogListener listener) {
super(context);
this.context=context;
this.listener = listener;
this.msg=msg;
binding = DialogConfirmBinding.inflate(getLayoutInflater());
mView = binding.getRoot();
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
}
public void setTvMsg(String msg) {
if (!TextUtils.isEmpty(msg)) {
binding.tvMsg.setText(msg);
}
}
public void setTvTitle(String title) {
if (!TextUtils.isEmpty(title)) {
binding.tvTitle.setText(title);
}
}
public void hideBottomClick() {
binding.bottomBtnView.bottomClick.setVisibility(View.GONE);
}
//获取屏幕宽度
public static int getScreenWidth(Context context) {
WindowManager manager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return manager.getCurrentWindowMetrics().getBounds().width();
}else{
Display display = manager.getDefaultDisplay();
return display.getWidth();
}
}
public interface ConfirmDialogListener {
void confirm();
}
}

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"/>
</shape>

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lay_dialog_bottom_view"
android:background="@drawable/radius"
android:orientation="vertical">
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="提示"
android:textColor="#000"
android:textSize="20sp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/gray" />
<TextView
android:id="@+id/tv_msg"
android:layout_width="match_parent"
android:layout_height="200px"
android:gravity="center"
android:text=""
android:textColor="#000"
android:textSize="40px"
android:textStyle="bold" />
<include
android:id="@+id/bottom_btn_view"
layout="@layout/layout_ba_check_dialog_bottom" />
</LinearLayout>

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/bottomClick"
android:layout_height="71px"
android:layout_marginTop="5px"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/lay_dialog_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="@drawable/shape_bottom_corner"
android:visibility="visible">
<TextView
android:background="@drawable/selector_list_item"
android:id="@+id/dialog_commit"
android:layout_width="0dp"
android:layout_height="70px"
android:layout_weight="8"
android:gravity="center"
android:maxLines="1"
android:padding="10px"
android:text="确定"
android:textColor="@color/bule"
android:textSize="35px"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Loading…
Cancel
Save