|
|
|
|
@ -1,12 +1,14 @@
|
|
|
|
|
package com.rehome.zhdcoa.ui.activity
|
|
|
|
|
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.widget.CheckBox
|
|
|
|
|
import com.google.gson.Gson
|
|
|
|
|
import com.google.gson.reflect.TypeToken
|
|
|
|
|
import com.luck.picture.lib.entity.LocalMedia
|
|
|
|
|
import com.rehome.zhdcoa.Contans
|
|
|
|
|
import com.rehome.zhdcoa.adapter.WorkTickerSelectListAdapter
|
|
|
|
|
import com.rehome.zhdcoa.adapter.WorkTickerSelectListAdapter.CallBack
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
|
import com.rehome.zhdcoa.bean.AIBaseBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.WorkRiskLevelListBean
|
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityWorkTickerSelectListBinding
|
|
|
|
|
import com.rehome.zhdcoa.utils.AuthenticationLoginAIUtils
|
|
|
|
|
@ -14,6 +16,7 @@ import com.rehome.zhdcoa.utils.GsonUtils
|
|
|
|
|
import com.rehome.zhdcoa.utils.HttpListener
|
|
|
|
|
import com.rehome.zhdcoa.utils.NohttpUtils
|
|
|
|
|
import com.rehome.zhdcoa.utils.RSAAndroid
|
|
|
|
|
import com.rehome.zhdcoa.weiget.ConfirmDialog
|
|
|
|
|
import com.rehome.zhdcoa.weiget.DatePickDialogNew
|
|
|
|
|
import com.yolanda.nohttp.NoHttp
|
|
|
|
|
import com.yolanda.nohttp.RequestMethod
|
|
|
|
|
@ -35,9 +38,13 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
|
|
|
|
|
|
|
|
|
|
private var datas: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
|
|
|
|
|
private lateinit var mAdapter: WorkTickerSelectListAdapter
|
|
|
|
|
//WorkTickerSelectListAdapter
|
|
|
|
|
|
|
|
|
|
private var selectList: MutableList<String> = mutableListOf()
|
|
|
|
|
//工作票主键数组,来源查询每日作业风险清单
|
|
|
|
|
private var ticketIdList : MutableList<Int> = mutableListOf()
|
|
|
|
|
//要取消的工作票主键
|
|
|
|
|
private var deleteIdList : MutableList<Int> = mutableListOf()
|
|
|
|
|
|
|
|
|
|
private var selectList: MutableList<Int> = mutableListOf()
|
|
|
|
|
private lateinit var calendar: Calendar
|
|
|
|
|
|
|
|
|
|
//格式化日期的对象(转化成习惯的时间格式)
|
|
|
|
|
@ -49,12 +56,23 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
|
|
|
|
|
|
|
|
|
|
override fun initView() {
|
|
|
|
|
|
|
|
|
|
initToolbar("已授权工作票", "") {
|
|
|
|
|
initToolbar("已许可工作票", "") {
|
|
|
|
|
//提交
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetToday()
|
|
|
|
|
|
|
|
|
|
val selectListStr = intent.getStringExtra("selectList")!!
|
|
|
|
|
showLog(selectListStr)
|
|
|
|
|
val gson = Gson()
|
|
|
|
|
// if("".equals(selectListStr))
|
|
|
|
|
val selectListTemp:MutableList<Int> = gson.fromJson<MutableList<Int>>(selectListStr,object:TypeToken<MutableList<Int>>() {}.type)
|
|
|
|
|
showLog(GsonUtils.GsonString(selectListTemp))
|
|
|
|
|
if(selectListTemp.isNotEmpty()){
|
|
|
|
|
selectList.addAll(selectListTemp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.tvSt.setOnClickListener(View.OnClickListener { view: View? ->
|
|
|
|
|
|
|
|
|
|
val dialog = DatePickDialogNew(
|
|
|
|
|
@ -76,16 +94,19 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
|
|
|
|
|
datas[i].isChecked = true
|
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
|
}
|
|
|
|
|
deleteIdList.clear()
|
|
|
|
|
} else {
|
|
|
|
|
for (i in datas.indices) {
|
|
|
|
|
datas[i].isChecked = false
|
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
|
}
|
|
|
|
|
if(selectList.size>0){
|
|
|
|
|
deleteIdList.addAll(selectList)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mAdapter = WorkTickerSelectListAdapter(this,datas,object:CallBack{
|
|
|
|
|
override fun Click(view: View,position:Int) {
|
|
|
|
|
mAdapter = WorkTickerSelectListAdapter(this,datas) { view, position ->
|
|
|
|
|
val checkBox = view as CheckBox
|
|
|
|
|
datas[position].isChecked = checkBox.isChecked
|
|
|
|
|
var count = 0
|
|
|
|
|
@ -94,17 +115,37 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
|
|
|
|
|
count++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!checkBox.isChecked){
|
|
|
|
|
if(selectList.size>0){
|
|
|
|
|
for (i in selectList.indices) {
|
|
|
|
|
if(selectList[i] == datas[position].id){
|
|
|
|
|
if(!deleteIdList.contains(selectList[i])){
|
|
|
|
|
deleteIdList.add(selectList[i])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binding.itemHead.cb.isChecked = count == datas.size
|
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
//binding.lv.addHeaderView(headView, null, false)
|
|
|
|
|
binding.lv.adapter = mAdapter
|
|
|
|
|
|
|
|
|
|
binding.tvSubmit.setOnClickListener {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var canSubmit = false
|
|
|
|
|
ticketIdList.clear()
|
|
|
|
|
for (i in datas.indices) {
|
|
|
|
|
if (datas[i].isChecked) {
|
|
|
|
|
canSubmit = true
|
|
|
|
|
ticketIdList.add(datas[i].id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (canSubmit) {
|
|
|
|
|
showLog(GsonUtils.GsonString(ticketIdList))
|
|
|
|
|
authenticationLoginAISubmit()
|
|
|
|
|
}else{
|
|
|
|
|
showToast("致少选择一个工作票才能提交")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//格式化日期的对象(转化成习惯的时间格式)
|
|
|
|
|
@ -173,6 +214,17 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
|
|
|
|
|
if (workRiskLevelLists != null && workRiskLevelLists.size > 0) {
|
|
|
|
|
binding.tvNodata.visibility = View.GONE
|
|
|
|
|
datas.clear()
|
|
|
|
|
|
|
|
|
|
if(selectList.size>0){
|
|
|
|
|
for (i in workRiskLevelLists.indices) {
|
|
|
|
|
for (j in selectList.indices) {
|
|
|
|
|
if (workRiskLevelLists[i].id==selectList[j]) {
|
|
|
|
|
workRiskLevelLists[i].isChecked = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datas.addAll(workRiskLevelLists)
|
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
|
|
|
|
|
|
@ -205,4 +257,84 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
|
|
|
|
|
binding.tvSt.text = startDateStr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun authenticationLoginAISubmit() {
|
|
|
|
|
try {
|
|
|
|
|
//AI三维登录接口
|
|
|
|
|
val userName = Contans.SP.AI_ACCOUNT
|
|
|
|
|
//String strPrivateEncode=RSAAndroid.encryptByPrivateKeyForSpiltStr(Contans.SP.AI_PWD,RSAAndroid.privateRsaKeyLocal);
|
|
|
|
|
val strPublicDecode = RSAAndroid.decryptByPublicKeyForSpiltStr(
|
|
|
|
|
Contans.SP.AI_PWD_ENCODE,
|
|
|
|
|
RSAAndroid.publicRsaKeyLocal
|
|
|
|
|
)
|
|
|
|
|
AuthenticationLoginAIUtils.authenticationAILoginShowProgress(
|
|
|
|
|
this, userName, strPublicDecode
|
|
|
|
|
) { _, token ->
|
|
|
|
|
if (token != null && token == "") {
|
|
|
|
|
showToast("AI三维平台登录失败")
|
|
|
|
|
} else {
|
|
|
|
|
submitWorkTicketData()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun getSubmitJsonData(): String {
|
|
|
|
|
val param = HashMap<String, Any>()
|
|
|
|
|
param["assignmentDate"] = binding.tvSt.text.toString().trim()
|
|
|
|
|
param["ticketIdList"] = ticketIdList
|
|
|
|
|
param["deleteIdList"]= deleteIdList
|
|
|
|
|
|
|
|
|
|
val json = GsonUtils.GsonString(param)
|
|
|
|
|
showLog(json)
|
|
|
|
|
return json
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun submitWorkTicketData() {
|
|
|
|
|
val request = NoHttp.createStringRequest(
|
|
|
|
|
Contans.BASE_URL_AI_3D_SERVER + Contans.DAYLY_RISK_LIST_SUBMIT_WORK_TICKET_LIST,
|
|
|
|
|
RequestMethod.POST
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val json: String = getSubmitJsonData()
|
|
|
|
|
request.setDefineRequestBodyForJson(json)
|
|
|
|
|
|
|
|
|
|
if (Contans.BASE_URL_AI_3D_SERVER == Contans.BASE_URL_AI_3D_SERVER_EXTRANET) {
|
|
|
|
|
val socketFactory = NohttpUtils.getSSLSocketFactory(context)
|
|
|
|
|
if (socketFactory != null) {
|
|
|
|
|
request.sslSocketFactory = socketFactory
|
|
|
|
|
request.hostnameVerifier = HostnameVerifier { _, _ -> true }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
|
|
|
|
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog("----------------")
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean = GsonUtils.GsonToBean(
|
|
|
|
|
result,
|
|
|
|
|
AIBaseBean::class.java
|
|
|
|
|
)
|
|
|
|
|
if (bean != null && bean.isSuccess) {
|
|
|
|
|
//提交成功
|
|
|
|
|
val confirmDialog = ConfirmDialog(
|
|
|
|
|
context, "设置工作票作业日期成功"
|
|
|
|
|
) { finish() }
|
|
|
|
|
confirmDialog.setTvTitle("提示")
|
|
|
|
|
confirmDialog.setCancelable(true)
|
|
|
|
|
confirmDialog.show()
|
|
|
|
|
}else{
|
|
|
|
|
showToast("设置工作票作业日期失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|