|
|
|
|
@ -3,11 +3,13 @@ package com.rehome.zhdcoa.ui.activity
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.os.Build
|
|
|
|
|
import android.text.TextUtils
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.widget.AdapterView
|
|
|
|
|
import androidx.activity.result.ActivityResultLauncher
|
|
|
|
|
import androidx.activity.result.contract.ActivityResultContracts
|
|
|
|
|
import com.google.gson.Gson
|
|
|
|
|
import com.rehome.zhdcoa.App
|
|
|
|
|
import com.rehome.zhdcoa.Contans
|
|
|
|
|
import com.rehome.zhdcoa.adapter.WhpListAdapter
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
|
@ -28,12 +30,15 @@ import com.rehome.zhdcoa.weiget.DateTimeMinutePickDialog
|
|
|
|
|
import com.rehome.zhdcoa.weiget.SaveOrCommitDialog
|
|
|
|
|
import com.yolanda.nohttp.NoHttp
|
|
|
|
|
import com.yolanda.nohttp.RequestMethod
|
|
|
|
|
import com.yolanda.nohttp.rest.OnResponseListener
|
|
|
|
|
import com.yolanda.nohttp.rest.RequestQueue
|
|
|
|
|
import com.yolanda.nohttp.rest.Response
|
|
|
|
|
import retrofit2.Call
|
|
|
|
|
import java.util.Calendar
|
|
|
|
|
|
|
|
|
|
class AddDagerEnterApplyActivity :
|
|
|
|
|
BaseActivityOaToolbarViewBinding<ActivityAddDagerEnterApplyBinding>() {
|
|
|
|
|
private lateinit var queueNoHttp: RequestQueue
|
|
|
|
|
private var isAudit = true
|
|
|
|
|
private var departmentId: String? = null
|
|
|
|
|
private var departmentName: String? = null
|
|
|
|
|
@ -54,6 +59,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
override fun getToolbar() = binding.toolbarView.toolbar
|
|
|
|
|
|
|
|
|
|
override fun initView() {
|
|
|
|
|
queueNoHttp = NoHttp.newRequestQueue(1)
|
|
|
|
|
isEdit = intent.getBooleanExtra("isEdit", false)
|
|
|
|
|
id = intent.getStringExtra("id")
|
|
|
|
|
launcherResult = createActivityResultLauncher()
|
|
|
|
|
@ -89,7 +95,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
val dialog = DateTimeMinutePickDialog(
|
|
|
|
|
context, calendar, true
|
|
|
|
|
) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? ->
|
|
|
|
|
binding.ilSQSJ.content = outPutDate
|
|
|
|
|
binding.ilSQSJ.content = outPutDate1
|
|
|
|
|
}
|
|
|
|
|
dialog.show()
|
|
|
|
|
}
|
|
|
|
|
@ -436,7 +442,10 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
map["SQRID"] = userInfo!!.manid
|
|
|
|
|
map["SQRDEPTID"] = userInfo!!.bzbh
|
|
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(Gson().toJson(map))
|
|
|
|
|
val json = Gson().toJson(map)
|
|
|
|
|
showLog(json)
|
|
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(json)
|
|
|
|
|
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
@ -445,7 +454,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast("新增危化品成功")
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
addWhpListByIDFirst(bean.id)
|
|
|
|
|
} else {
|
|
|
|
|
showToast("新增危化品失败")
|
|
|
|
|
}
|
|
|
|
|
@ -489,4 +498,61 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
}
|
|
|
|
|
}, true, true, "提交数据中...")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新增危化品清单
|
|
|
|
|
private fun addWhpListByIDFirst(whpId: String) {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_ADD_ITEM_LIST_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
|
|
if (App.getInstance().userInfo != null && App.getInstance().userInfo.token != null) {
|
|
|
|
|
val token = App.getInstance().userInfo.token
|
|
|
|
|
val credential = "Bearer $token"
|
|
|
|
|
request.addHeader("Authorization", credential)
|
|
|
|
|
Log.i("app", request.url())
|
|
|
|
|
// Log.i("app", credential);
|
|
|
|
|
// Log.i("app",new Gson().toJson(request.headers()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var whpSubmitSuccessCount = 0
|
|
|
|
|
for (i in whpList.indices) {
|
|
|
|
|
val item = whpList[i]
|
|
|
|
|
item.mainid = whpId
|
|
|
|
|
|
|
|
|
|
val json = Gson().toJson(item)
|
|
|
|
|
showLog(json)
|
|
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(json)
|
|
|
|
|
queueNoHttp.add<String>(3, request, object : OnResponseListener<String> {
|
|
|
|
|
override fun onStart(what: Int) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String>?) {
|
|
|
|
|
if (what == 3) {
|
|
|
|
|
whpSubmitSuccessCount++
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? =
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
if (whpSubmitSuccessCount == whpList.size) {
|
|
|
|
|
showToast("新增危化品申请成功")
|
|
|
|
|
finish()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showToast("新增危化品清单失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFinish(what: Int) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|