|
|
|
|
@ -45,9 +45,6 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
private var isEdit = false;
|
|
|
|
|
private var id: String? = null;
|
|
|
|
|
private val whpList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
// private val whpDeleteList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
// private val whpChangeList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
|
|
|
|
|
private lateinit var adapter: WhpListAdapter
|
|
|
|
|
|
|
|
|
|
private val userInfos: ArrayList<StaffInfoBean.StaffInfo> = ArrayList()
|
|
|
|
|
@ -122,23 +119,13 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
|
|
|
|
|
//创建一个ActivityResultLauncher,添加一条危化品清单数据
|
|
|
|
|
private fun saveOrCommitApply(isSubmit: Boolean) {
|
|
|
|
|
if (isSubmit) {
|
|
|
|
|
//保存并提交
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
//编辑,新增一条危化品清单
|
|
|
|
|
//addWhpListByID(item)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//仅保存
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
//编辑
|
|
|
|
|
updateWhpByFirst(isSubmit)
|
|
|
|
|
} else {
|
|
|
|
|
//仅保存
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
//编辑
|
|
|
|
|
updateWhpByFirst()
|
|
|
|
|
} else {
|
|
|
|
|
//新增
|
|
|
|
|
addWhpByFirst()
|
|
|
|
|
}
|
|
|
|
|
//新增
|
|
|
|
|
addWhpByFirst(isSubmit)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -429,7 +416,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新增危化品入厂申请
|
|
|
|
|
private fun addWhpByFirst() {
|
|
|
|
|
private fun addWhpByFirst(isSubmit: Boolean) {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_ADD_WHP_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
|
|
@ -453,8 +440,8 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? =
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast("新增危化品成功")
|
|
|
|
|
addWhpListByIDFirst(bean.id)
|
|
|
|
|
//showToast("新增危化品成功")
|
|
|
|
|
addWhpListByIDFirst(bean.id, isSubmit)
|
|
|
|
|
} else {
|
|
|
|
|
showToast("新增危化品失败")
|
|
|
|
|
}
|
|
|
|
|
@ -467,7 +454,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改危化品入厂申请
|
|
|
|
|
private fun updateWhpByFirst() {
|
|
|
|
|
private fun updateWhpByFirst(isSubmit: Boolean) {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_UPDATE_WHP_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
|
|
@ -488,6 +475,9 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast("修改危化品成功")
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
if (isSubmit) {
|
|
|
|
|
submitWhpById(bean.id)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showToast("修改危化品失败")
|
|
|
|
|
}
|
|
|
|
|
@ -500,18 +490,8 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新增危化品清单
|
|
|
|
|
private fun addWhpListByIDFirst(whpId: String) {
|
|
|
|
|
private fun addWhpListByIDFirst(whpId: String, isSubmit: Boolean) {
|
|
|
|
|
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) {
|
|
|
|
|
@ -521,6 +501,14 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
val json = Gson().toJson(item)
|
|
|
|
|
showLog(json)
|
|
|
|
|
|
|
|
|
|
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())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(json)
|
|
|
|
|
queueNoHttp.add<String>(3, request, object : OnResponseListener<String> {
|
|
|
|
|
override fun onStart(what: Int) {
|
|
|
|
|
@ -536,8 +524,12 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
if (whpSubmitSuccessCount == whpList.size) {
|
|
|
|
|
showToast("新增危化品申请成功")
|
|
|
|
|
finish()
|
|
|
|
|
if (isSubmit) {
|
|
|
|
|
submitWhpById(whpId)
|
|
|
|
|
}else{
|
|
|
|
|
showToast("保存危化品申请成功")
|
|
|
|
|
finish()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showToast("新增危化品清单失败")
|
|
|
|
|
@ -555,4 +547,33 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//提交危化品入厂申请
|
|
|
|
|
private fun submitWhpById(whpId: String) {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_SUBMIT_WHP_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
|
|
val map: MutableMap<String, String> = mutableMapOf()
|
|
|
|
|
map["ID"] = whpId
|
|
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(Gson().toJson(map))
|
|
|
|
|
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: DagerEnterApplyBaseBean? =
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast("提交危化品入厂申请成功")
|
|
|
|
|
finish()
|
|
|
|
|
} else {
|
|
|
|
|
showToast("提交危化品入厂申请失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, true, true, "提交数据中...")
|
|
|
|
|
}
|
|
|
|
|
}
|