作业风险清单 增加手动添加入口,工作票,辅助工作 增加type字段

master
wenfei 4 months ago
parent ef0c6dc1cb
commit 431774ac49

@ -1132,11 +1132,15 @@
<activity
android:name=".ui.activity.CustomDialogChangeLevelActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Dialog"/>
android:theme="@android:style/Theme.Dialog" />
<activity
android:name=".ui.activity.WorkTickerSelectListActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" /> <!-- 作业风险清单-右上角工作票 点击进入已审批通过的工作票汇列表选择 -->
<activity
android:name=".ui.activity.WorkTickerAssistantSelectListActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" /> <!-- 作业风险清单-右上角工作票 点击进入已审批通过的辅助工作票汇列表选择 -->
<activity
android:name=".ui.activity.WorkRiskListHuiBaoActivity"
android:screenOrientation="portrait"

@ -558,8 +558,11 @@ public class Contans {
//查询每日作业风险清单新接口
public final static String DAYLY_RISK_LIST_NEW = "sc_v1/api/ticket/active/listSummaryTicketAndLevel";
//查询已许可辅助工作
public final static String DAYLY_RISK_LIST_NEW_ASSISTANT = "sc_v1/api/assistingWork/list";
//每日作业风险清单 修改每日作业风险等级
public final static String UPDATE_RISK_LEVEL = "/sc_v1/api/ticket/level/update";
public final static String UPDATE_RISK_LEVEL = "sc_v1/api/ticket/level/update";
//通讯录
public static String GETCONTACTLIST_URL="PubFile/Data/GetAddressbookRsa.ashx";

@ -0,0 +1,383 @@
package com.rehome.zhdcoa.base
import android.app.Activity
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.ApplicationInfo
import android.nfc.NdefMessage
import android.nfc.NfcAdapter
import android.nfc.tech.IsoDep
import android.nfc.tech.MifareClassic
import android.nfc.tech.MifareUltralight
import android.nfc.tech.NfcA
import android.nfc.tech.NfcB
import android.nfc.tech.NfcF
import android.nfc.tech.NfcV
import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.widget.EditText
import android.widget.Toast
import androidx.viewbinding.ViewBinding
import com.rehome.zhdcoa.App
import com.rehome.zhdcoa.R
import com.rehome.zhdcoa.bean.UserInfoBean
import com.rehome.zhdcoa.utils.ControllerActivity
import com.rehome.zhdcoa.utils.StatusBarUtil
import com.rehome.zhdcoa.weiget.OAToolbarTwo
import com.zhy.autolayout.AutoLayoutActivity
import java.nio.charset.StandardCharsets
import java.util.Locale
/**
* Create By HuangWenFei
* 创建日期2023-01-30 11:11
* 描述基类使用ViewBindingButterKnife已被作者废弃不再维护
*/
abstract class BaseActivityOaToolbarTwoViewBinding<T : ViewBinding> : AutoLayoutActivity() {
val REQUEST_CODE_ADD = 1
val REQUEST_CODE_AUDIT = 2
var userInfo: UserInfoBean.UserInfo? = null
protected lateinit var binding: T
protected lateinit var mToolbar: OAToolbarTwo
protected lateinit var context: Context
private var nfcAdapter: NfcAdapter? = null
private var readResult = ""
private var pendingIntent: PendingIntent? = null
private lateinit var mFilters: Array<IntentFilter>
private lateinit var mTechLists: Array<Array<String>>
private var isFirst = true
private var ndef: IntentFilter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = getViewBinding()
mToolbar = getToolbar()
setContentView(binding.root)
context = this
ControllerActivity.getAppManager().addActivity(this)
userInfo = App.getInstance().userInfo
initView()
initData()
}
//初始化ViewBinding
protected abstract fun getViewBinding(): T
//初始化OAToolbar
protected abstract fun getToolbar(): OAToolbarTwo
//初始化View
protected abstract fun initView()
//初始化数据
protected abstract fun initData()
fun startActivity(cls: Class<out Activity?>?) {
val intent = Intent(this, cls)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
startActivity(intent)
}
override fun onPause() {
super.onPause()
if (nfcAdapter != null) {
nfcAdapter!!.disableForegroundDispatch(this)
}
}
/*
* 重写onResume回调函数的意义在于处理多次读取NFC标签时的情况
*/
override fun onResume() {
super.onResume()
// 前台分发系统,这里的作用在于第二次检测NFC标签时该应用有最高的捕获优先权.
if (nfcAdapter != null && pendingIntent != null) {
nfcAdapter!!.enableForegroundDispatch(
this, pendingIntent, mFilters,
mTechLists
)
}
}
override fun onDestroy() {
super.onDestroy()
ControllerActivity.getAppManager().finishActivity(this)
}
/**
* 显示toast
*
* @param text
*/
fun showToast(text: String) {
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
}
fun showToast(id: Int) {
Toast.makeText(this, id, Toast.LENGTH_SHORT).show()
}
/**
* 检测工作,判断设备的NFC支持情况
*
* @return
*/
private fun ifNFCUse(): Boolean {
if (nfcAdapter == null) {
Toast.makeText(this, "设备不支持NFC", Toast.LENGTH_SHORT).show()
return false
}
if (!nfcAdapter!!.isEnabled) {
Toast.makeText(this, "请在系统设置中先启用NFC功能", Toast.LENGTH_SHORT).show()
return false
}
return true
}
/**
* 初始化过程
*/
fun initNFC() {
//NFC适配器所有的关于NFC的操作从该适配器进行
nfcAdapter = NfcAdapter.getDefaultAdapter(this)
if (!ifNFCUse()) {
return
}
//将被调用的Intent用于重复被Intent触发后将要执行的跳转
pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.getActivity(
this,
0,
Intent(this, javaClass).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
} else {
PendingIntent.getActivity(
this,
0,
Intent(this, javaClass).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
PendingIntent.FLAG_UPDATE_CURRENT
)
}
//设定要过滤的标签动作这里只接收ACTION_NDEF_DISCOVERED类型
ndef = IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED)
ndef!!.addCategory("*/*")
mFilters = arrayOf(ndef!!) // 过滤器
mTechLists = arrayOf(
arrayOf(NfcA::class.java.name), arrayOf(
NfcF::class.java.name
), arrayOf(NfcB::class.java.name), arrayOf(
NfcV::class.java.name
), arrayOf(MifareClassic::class.java.name), arrayOf(
MifareUltralight::class.java.name
), arrayOf(IsoDep::class.java.name)
) // 允许扫描的标签类型
if (isFirst) {
if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent
.action
) {
ndef = IntentFilter()
if (readFromTag(intent)) {
Toast.makeText(this, readResult, Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "标签数据为空", Toast.LENGTH_SHORT).show()
}
}
isFirst = false
}
}
// private fun byteArrayToHexString(src: ByteArray?): String {
// //converts byte arrays to string
// if (src == null || src.isEmpty()) {
// return ""
// }
// var i: Int
// var j: Int=0
// var k: Int
// val hex = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
// var out = ""
// while (j < src.size) {
// k = src[j].toInt() and 0xff
// i = k shr 4 and 0x0f
// out += hex[i]
// i = k and 0x0f
// out += hex[i]
// ++j
// }
// return out
// }
/**
* 2进制to 16进制
* @param src
* @return
*/
private fun bytesToHex(src: ByteArray?): String {
val sb = StringBuffer()
if (src == null || src.isEmpty()) {
return ""
}
var sTemp: String
for (i in src.indices) {
sTemp = Integer.toHexString(0xFF and src[i].toInt())
if (sTemp.length < 2) {
sb.append(0)
}
sb.append(sTemp.uppercase(Locale.getDefault()))
}
return sb.toString()
}
/*
* 有必要要了解onNewIntent回调函数的调用时机,请自行上网查询
*/
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action || NfcAdapter.ACTION_TECH_DISCOVERED == intent.action) {
val id = bytesToHex(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID))
handleNfc(id)
}
}
/**
* 读取NFC标签数据的操作
*/
private fun readFromTag(intent: Intent): Boolean {
if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action) {
val rawArray = intent
.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)
if (rawArray != null) {
val mNdefMsg = rawArray[0] as NdefMessage
val mNdefRecord = mNdefMsg.records[0]
if (mNdefRecord != null) {
readResult = String(mNdefRecord.payload, StandardCharsets.UTF_8)
return true
}
}
return false
}
return false
}
//处理NFC
open fun handleNfc(result: String) {
//showToast(result);
}
open fun initToolbar(title: String) {
mToolbar.setTvTitleText(title)
}
open fun setToolbarTitle(title: String) {
mToolbar.setTvTitleText(title)
}
open fun setTvRightTitle(text: String) {
mToolbar.setTvRightText(text)
}
open fun setLeftOnClickListener(listener: View.OnClickListener?) {
mToolbar.setIvLeftOnClickListener(listener)
mToolbar.setIvLeftIcon(R.drawable.ac_back_icon)
}
open fun getText(editText: EditText): String {
return editText.text.toString()
}
open fun setToolbarColor() {
mToolbar.setBackgroundColor(resources.getColor(R.color.lucency))
mToolbar.setTvTitleColor(resources.getColor(R.color.login_title_color))
}
protected open fun setStatusBar() {
StatusBarUtil.setColor(this, resources.getColor(R.color.colorPrimary))
}
fun initToolbar(
title: String,
rightText: String,
listenerRightClick: View.OnClickListener
) {
mToolbar.setTvTitleText(title)
mToolbar.setTvRightText(rightText)
mToolbar.setIvLeftIcon(R.drawable.ac_back_icon)
mToolbar.setIvLeftOnClickListener {
finish()
}
mToolbar.setTvRightOnClickListener(listenerRightClick)
}
fun initToolbar(
title: String,
rightText: String,
listenerLeftClick: View.OnClickListener,
listenerRightClick: View.OnClickListener
) {
mToolbar.setTvTitleText(title)
mToolbar.setTvRightText(rightText)
mToolbar.setIvLeftIcon(R.drawable.ac_back_icon)
mToolbar.setIvLeftOnClickListener(listenerLeftClick)
mToolbar.setTvRightOnClickListener(listenerRightClick)
}
fun initToolbar(
title: String,
rightText: String,
listenerLeftClick: View.OnClickListener,
listenerRightClick: View.OnClickListener,
listenerRightBottomClick: View.OnClickListener
) {
mToolbar.setTvTitleText(title)
mToolbar.setTvRightText(rightText)
mToolbar.setIvLeftIcon(R.drawable.ac_back_icon)
mToolbar.setIvLeftOnClickListener(listenerLeftClick)
mToolbar.setTvRightOnClickListener(listenerRightClick)
mToolbar.setTvRightBottomOnClickListener(listenerRightBottomClick)
}
fun initToolbar(
title: String,
rightTextId: Int,
listenerLeftClick: View.OnClickListener,
listenerRightClick: View.OnClickListener
) {
mToolbar.setTvTitleText(title)
mToolbar.setTvRightText(rightTextId)
mToolbar.setIvLeftIcon(R.drawable.ac_back_icon)
mToolbar.setIvLeftOnClickListener(listenerLeftClick)
mToolbar.setTvRightOnClickListener(listenerRightClick)
}
open fun showLog(logText: String?) {
if (isApkInDebug(context)) {
if (TextUtils.isEmpty(logText)) {
Log.i("app", "logText is null")
} else {
Log.i("app", logText!!)
}
}
}
/**
* 判断当前应用是否是debug状态
*/
fun isApkInDebug(context: Context): Boolean {
try {
val info = context.applicationInfo
return (info.flags and ApplicationInfo.FLAG_DEBUGGABLE) != 0
} catch (e: Exception) {
return false
}
}
}

@ -26,7 +26,7 @@ public class WorkRiskLevelListBean extends AIBaseBean{
//工作内容
private String content;
//记录号
private int number;
private String number;
//工作票ID
private Integer id;
//工作票状态
@ -35,7 +35,12 @@ public class WorkRiskLevelListBean extends AIBaseBean{
private String major;
//设置工作票人工号
private String jobNo;
//作业风险信息类型 ticket工作票 assisting辅助工作 custom自定义
private String type;
//风险源危害对象数组
private List<HazardListBean> hazardList;
//工单编号
private String orderNo;
private boolean checked;//0:未选中,1:已选中
public String getCode() {
@ -54,11 +59,11 @@ public class WorkRiskLevelListBean extends AIBaseBean{
this.content = content;
}
public int getNumber() {
public String getNumber() {
return number;
}
public void setNumber(int number) {
public void setNumber(String number) {
this.number = number;
}
@ -117,5 +122,21 @@ public class WorkRiskLevelListBean extends AIBaseBean{
public void setJobNo(String jobNo) {
this.jobNo = jobNo;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
}
}

@ -35,6 +35,7 @@ class CustomDialogChangeLevelActivity : Activity() {
private var id: Int?=null
private var level: String?=null
private var type: String?=null
override fun onCreate(savedInstanceState: Bundle?) {
@ -50,6 +51,7 @@ class CustomDialogChangeLevelActivity : Activity() {
id = intent.getIntExtra("id", 0)
level = intent.getStringExtra("level")
type = intent.getStringExtra("type")
if(level!=null){
if("A" == level){
binding.rb1.isChecked = true
@ -260,6 +262,7 @@ class CustomDialogChangeLevelActivity : Activity() {
}
param["jobNo"]= App.getInstance().userInfo.manid
param["type"]=type?:"ticket"
if(binding.rb1.isChecked){
param["level"] = "A"

@ -174,6 +174,79 @@ class LoginActivity : BaseActivityOaToolbarViewBinding<ActivityLoginBinding>() {
if (isApkInDebug(context)) {
// 管理员
binding.etUsername.setText("ZHPS_Admin")
binding.etPassword.setText("Rehome.zhps@996")
//公司内网215管理员
// binding.etUsername.setText("ZHPS_Admin")
// binding.etPassword.setText("Rehome.zhps@2020")
// binding.etUsername.setText("310353")
// binding.etPassword.setText("Zhps1382.")
// binding.etUsername.setText("310691")
// binding.etPassword.setText("Abcd*1234")
// binding.etUsername.setText("990001")
// binding.etPassword.setText("Bwfb@123")
// binding.etUsername.setText("310295")
// binding.etPassword.setText("Whk363521!")
// binding.etUsername.setText("310675")
// binding.etPassword.setText("Mj12345_")
//吴云强
// binding.etUsername.setText("310430")
// binding.etPassword.setText("Laq**201610")
//马
// binding.etUsername.setText("310482")
// binding.etPassword.setText("Maying2008!")
// 生产岗位 卢高波 可以进入巡视抄表
// binding.etUsername.setText("310492")
// binding.etPassword.setText("Dudu520520@")
//李昕逸 可以进入巡视抄表
// binding.etUsername.setText("310677")
// binding.etPassword.setText("LXY1997.qaz")
//陈坚标
// binding.etUsername.setText("310063")
// binding.etPassword.setText("ZHPs@040909")
////郑佩障
// binding.etUsername.setText("310569")
// binding.etPassword.setText("sUnnY@0926")
//谭添欢
// binding.etUsername.setText("310273")
// binding.etPassword.setText("#Tth8680004")
//吴云强
// binding.etUsername.setText("310430")
// binding.etPassword.setText("Laq@201610")
//欧建荣
// binding.etUsername.setText("310285")
// binding.etPassword.setText("@Ojr310285")
// binding.etUsername.setText("310561")
// binding.etPassword.setText("Yangjing!0561")
// binding.etUsername.setText("310534")
// binding.etPassword.setText("abCd*1234")
// binding.etUsername.setText("310291")
// binding.etPassword.setText("sfd02910291Z+")
// binding.etUsername.setText("310465")
// binding.etPassword.setText("Liu524042*")
// binding.etUsername.setText("310291")
// binding.etPassword.setText("sfd02910291Z+")
}

@ -9,6 +9,7 @@ import androidx.activity.result.contract.ActivityResultContracts
import com.rehome.zhdcoa.Contans
import com.rehome.zhdcoa.R
import com.rehome.zhdcoa.adapter.WorkRiskLevelListAdapter
import com.rehome.zhdcoa.base.BaseActivityOaToolbarTwoViewBinding
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
import com.rehome.zhdcoa.bean.WorkRiskLevelListBean
import com.rehome.zhdcoa.completionUtil.ReplaceSpan
@ -41,6 +42,9 @@ class WorkRiskListActivity : BaseActivityOaToolbarViewBinding<ActivityWorkRiskLi
private var selectList: MutableList<Int> = mutableListOf()
private var jobNoList: MutableList<String> = mutableListOf()
private var selectListAssistant: MutableList<Int> = mutableListOf()
private var jobNoListAssistant: MutableList<String> = mutableListOf()
private var dataA: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataB: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataC1: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
@ -57,19 +61,9 @@ class WorkRiskListActivity : BaseActivityOaToolbarViewBinding<ActivityWorkRiskLi
override fun initView() {
initToolbar("每日作业风险清单", "",{
initToolbar("每日作业风险清单", "工作票") {
if(isNetworkNormal){
//进入风险提示页面 WorkTickerSelectListActivity
val intent = Intent(context, WorkTickerSelectListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("selectList", GsonUtils.GsonString(selectList))
intent.putExtra("jobNoList", GsonUtils.GsonString(jobNoList))
startActivity(intent)
}else{
showToast("列表数据加载失败,请检查网络环境或重新加载列表数据")
}
}
})
launcherResultQRCode = createQRCodeActivityResultLauncher()
@ -95,6 +89,7 @@ class WorkRiskListActivity : BaseActivityOaToolbarViewBinding<ActivityWorkRiskLi
intent.putExtra("id",item.id)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("level", item.level)
intent.putExtra("type", item.type)
launcherResultQRCode.launch(intent)
}
},
@ -115,6 +110,46 @@ class WorkRiskListActivity : BaseActivityOaToolbarViewBinding<ActivityWorkRiskLi
binding.llRefresh.setOnClickListener { authenticationLoginAI() }
binding.llWorkTicket.setOnClickListener {
if(isNetworkNormal){
//进入风险提示页面 WorkTickerSelectListActivity
val intent = Intent(context, WorkTickerSelectListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("selectList", GsonUtils.GsonString(selectList))
intent.putExtra("jobNoList", GsonUtils.GsonString(jobNoList))
startActivity(intent)
}else{
//WorkTickerAssistantSelectListActivity
showToast("列表数据加载失败,请检查网络环境或重新加载列表数据")
}
}
binding.llAssiting.setOnClickListener {
if(isNetworkNormal){
//进入风险提示页面 WorkTickerAssistantSelectListActivity
val intent = Intent(context, WorkTickerAssistantSelectListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("selectList", GsonUtils.GsonString(selectListAssistant))
intent.putExtra("jobNoList", GsonUtils.GsonString(jobNoListAssistant))
startActivity(intent)
}else{
showToast("列表数据加载失败,请检查网络环境或重新加载列表数据")
}
}
binding.llCustomAdd.setOnClickListener {
if(isNetworkNormal){
//进入风险提示页面 WorkTickerAssistantSelectListActivity
val intent = Intent(context, WorkTickerAssistantSelectListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("selectList", GsonUtils.GsonString(selectListAssistant))
intent.putExtra("jobNoList", GsonUtils.GsonString(jobNoListAssistant))
startActivity(intent)
}else{
showToast("列表数据加载失败,请检查网络环境或重新加载列表数据")
}
}
//格式化日期的对象(转化成习惯的时间格式)
val sdFormat = SimpleDateFormat("yyyy.MM.dd")
//静态方法getInstance()使用默认时区和语言环境获得一个日历。
@ -222,9 +257,20 @@ class WorkRiskListActivity : BaseActivityOaToolbarViewBinding<ActivityWorkRiskLi
selectList.clear()
jobNoList.clear()
selectListAssistant.clear()
jobNoListAssistant.clear()
for(item in datas){
selectList.add(item.id)
jobNoList.add(item.jobNo)
if("ticket" == item.type){
selectList.add(item.id)
jobNoList.add(item.jobNo)
}
if("assisting" == item.type){
selectListAssistant.add(item.id)
jobNoListAssistant.add(item.jobNo)
}
showLog(GsonUtils.GsonString(item))
if(item.level!=null&&item.level=="A"){
dataA.add(item)
@ -297,24 +343,6 @@ class WorkRiskListActivity : BaseActivityOaToolbarViewBinding<ActivityWorkRiskLi
datas.addAll(dataLowRisk)
mAdapter.notifyDataSetChanged()
}
// binding.tvADesc.setOnClickListener {
// toWorkRiskListHuiBaoActivity("A")
// }
// binding.tvBDesc.setOnClickListener {
// toWorkRiskListHuiBaoActivity("B")
// }
// binding.tvC1Desc.setOnClickListener {
// toWorkRiskListHuiBaoActivity("C1")
// }
// binding.tvC2Desc.setOnClickListener {
// toWorkRiskListHuiBaoActivity("C2")
// }
// binding.tvC3Desc.setOnClickListener {
// toWorkRiskListHuiBaoActivity("C3")
// }
// binding.tvLowLiskDesc.setOnClickListener {
// toWorkRiskListHuiBaoActivity("low")
// }
binding.tvReport.setOnClickListener {
val intent = Intent(context, WorkRiskListReportActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)

@ -0,0 +1,360 @@
package com.rehome.zhdcoa.ui.activity
import android.content.DialogInterface
import android.graphics.Color
import android.view.View
import android.widget.CheckBox
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.rehome.zhdcoa.App
import com.rehome.zhdcoa.Contans
import com.rehome.zhdcoa.adapter.WorkTickerSelectListAdapter
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
import com.rehome.zhdcoa.bean.AIBaseBean
import com.rehome.zhdcoa.bean.WorkRiskLevelListBean
import com.rehome.zhdcoa.databinding.ActivityWorkTickerAssistantSelectListBinding
import com.rehome.zhdcoa.databinding.ActivityWorkTickerSelectListBinding
import com.rehome.zhdcoa.utils.AuthenticationLoginAIUtils
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.CommitDialog
import com.rehome.zhdcoa.weiget.CommitDialog.CommitDialogListener
import com.rehome.zhdcoa.weiget.ConfirmDialog
import com.rehome.zhdcoa.weiget.DatePickDialogNew
import com.yolanda.nohttp.NoHttp
import com.yolanda.nohttp.RequestMethod
import com.yolanda.nohttp.rest.Response
import java.text.SimpleDateFormat
import java.util.Calendar
import javax.net.ssl.HostnameVerifier
/**
* Create By HuangWenFei
* 创建日期2025-02-6 15:31
* 描述已审批的工作票
*/
class WorkTickerAssistantSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWorkTickerAssistantSelectListBinding>() {
//private lateinit var headView: View
//private lateinit var cb: CheckBox
private var datas: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private lateinit var mAdapter: WorkTickerSelectListAdapter
//工作票主键数组,来源查询每日作业风险清单
private var ticketIdList : MutableList<Int> = mutableListOf()
//要取消的工作票主键
private var deleteIdList : MutableList<Int> = mutableListOf()
private var selectList: MutableList<Int> = mutableListOf()
private var jobNoList: MutableList<String> = mutableListOf()
private lateinit var calendar: Calendar
//格式化日期的对象(转化成习惯的时间格式)
private val sdFormat = SimpleDateFormat("yyyy-MM-dd")
override fun getViewBinding() = ActivityWorkTickerAssistantSelectListBinding.inflate(layoutInflater)
override fun getToolbar() = binding.toolbarView.toolbar
override fun initView() {
initToolbar("已许可辅助工作票", "") {
//提交
}
resetToday()
val selectListStr = intent.getStringExtra("selectList")!!
showLog(selectListStr)
val gson = Gson()
val selectListTemp:MutableList<Int> = gson.fromJson<MutableList<Int>>(selectListStr,object:TypeToken<MutableList<Int>>() {}.type)
showLog(GsonUtils.GsonString(selectListTemp))
if(selectListTemp.isNotEmpty()){
selectList.addAll(selectListTemp)
}
val jobNoListStr = intent.getStringExtra("jobNoList")!!
showLog(jobNoListStr)
val jobNoListTemp:MutableList<String> = gson.fromJson<MutableList<String>>(jobNoListStr,object:TypeToken<MutableList<String>>() {}.type)
showLog(GsonUtils.GsonString(jobNoListTemp))
if(jobNoListTemp.isNotEmpty()){
jobNoList.addAll(jobNoListTemp)
}
binding.tvSt.setOnClickListener(View.OnClickListener { view: View? ->
val dialog = DatePickDialogNew(
context, calendar
) { outPutDate: String,calendarBack:Calendar ->
binding.tvSt.text = outPutDate
calendar = calendarBack;
//checkServerConnectStatus()
}
dialog.show()
})
binding.lv.emptyView = binding.tvNodata
//headView = View.inflate(this, R.layout.header_work_ticket_select_list, null)
//cb = headView.findViewById<View>(R.id.cb) as CheckBox
binding.itemHead.cb.setOnClickListener {
if (binding.itemHead.cb.isChecked) {
for (i in datas.indices) {
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) { view, position ->
val checkBox = view as CheckBox
datas[position].isChecked = checkBox.isChecked
var count = 0
for (a in datas.indices) {
if (datas[a].isChecked) {
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.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||deleteIdList.size>0) {
val dialog = CommitDialog(context, object : CommitDialogListener {
override fun confirm() {
showLog(GsonUtils.GsonString(ticketIdList))
authenticationLoginAISubmit()
}
override fun cancel() {
}
})
dialog.setTvMsg("您确定要设置辅助工作票作业?")
dialog.show()
}else{
showToast("致少选择一个工作票才能提交")
}
}
}
override fun initData() {
authenticationLoginAI()
}
private fun authenticationLoginAI() {
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 {
getWorkRiskListData()
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun getWorkRiskListData() {
val url = Contans.BASE_URL_AI_3D_SERVER + Contans.DAYLY_RISK_LIST_NEW_ASSISTANT
val request = NoHttp.createStringRequest(url,RequestMethod.GET)
//request.add("filter",false);
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(url)
showLog(result)
val bean = GsonUtils.GsonToBean(
result,
WorkRiskLevelListBean::class.java
)
if (bean != null && bean.data != null) {
val workRiskLevelLists = bean.data
if (workRiskLevelLists != null && workRiskLevelLists.isNotEmpty()) {
binding.tvNodata.visibility = View.GONE
datas.clear()
if(selectList.isNotEmpty()){
for (i in workRiskLevelLists.indices) {
for (j in selectList.indices) {
if (workRiskLevelLists[i].id==selectList[j]) {
workRiskLevelLists[i].isChecked = true
workRiskLevelLists[i].jobNo = jobNoList[j]
}
}
}
}
datas.addAll(workRiskLevelLists)
mAdapter.notifyDataSetChanged()
for(item in datas){
showLog(GsonUtils.GsonString(item))
// if(item.level!=null&&item.level=="A"){
// dataA.add(item)
// }
}
} else {
binding.tvNodata.visibility = View.VISIBLE
}
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
}
})
}
private fun resetToday(){
calendar = Calendar.getInstance()
val startDateStr = sdFormat.format(calendar.time)
showLog("今天:")
showLog(startDateStr)
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
param["jobNo"]= App.getInstance().userInfo.manid
param["type"]= "assisting"
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?>?) {
}
})
}
}

@ -155,7 +155,7 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
ticketIdList.add(datas[i].id)
}
}
if (canSubmit) {
if (canSubmit||deleteIdList.size>0) {
val dialog = CommitDialog(context, object : CommitDialogListener {
override fun confirm() {
showLog(GsonUtils.GsonString(ticketIdList))
@ -304,6 +304,7 @@ class WorkTickerSelectListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
param["ticketIdList"] = ticketIdList
param["deleteIdList"]= deleteIdList
param["jobNo"]= App.getInstance().userInfo.manid
param["type"]= "ticket"
val json = GsonUtils.GsonString(param)
showLog(json)

@ -0,0 +1,149 @@
package com.rehome.zhdcoa.weiget;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.TintTypedArray;
import androidx.appcompat.widget.Toolbar;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import com.rehome.zhdcoa.R;
/**
* Created by Rehome-rjb1 on 2017/5/8.
*
*
*/
public class OAToolbarTwo extends Toolbar {
private LayoutInflater inflater;
private View view;
private TextView tvTitle;
private TextView tvRight;
private TextView tvRightBottom;
private ImageButton ivLeft;
public OAToolbarTwo(Context context) {
super(context, null);
}
@SuppressLint("RestrictedApi")
public OAToolbarTwo(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initView();
setContentInsetsRelative(10, 10);
if (attrs != null) {
@SuppressLint("RestrictedApi") final TintTypedArray tta = TintTypedArray.obtainStyledAttributes(getContext(), attrs, R.styleable.OAToolbar);
@SuppressLint("RestrictedApi") String title = tta.getString(R.styleable.OAToolbar_tvTitle);
@SuppressLint("RestrictedApi") String tvRightText = tta.getString(R.styleable.OAToolbar_tvRight);
@SuppressLint("RestrictedApi") Drawable drawable = tta.getDrawable(R.styleable.OAToolbar_ivLeftIcon);
setIvLeftIcon(drawable);
if (!TextUtils.isEmpty(title)) {
setTvTitleText(title);
}
if (!TextUtils.isEmpty(tvRightText)) {
setTvRightText(tvRightText);
}
tta.recycle();
}
}
public OAToolbarTwo(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
private void initView() {
inflater = LayoutInflater.from(getContext());
if (view == null) {
view = inflater.inflate(R.layout.toolbartwo, null);
tvTitle = view.findViewById(R.id.tv_title);
tvRight = view.findViewById(R.id.tv_right);
tvRightBottom = view.findViewById(R.id.tv_rightBottom);
ivLeft = view.findViewById(R.id.iv_left);
//然后使用LayoutParams把控件添加到子view中
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL);
addView(view, lp);
}
}
public void setTvTitleText(String text) {
if (tvTitle != null) {
tvTitle.setText(text);
}
}
public void setTvTitleColor(int color) {
if (tvTitle != null) {
tvTitle.setTextColor(color);
}
}
public void setTvRightText(String text) {
if (tvRight != null) {
tvRight.setVisibility(VISIBLE);
tvRight.setText(text);
}
}
public void setTvRightTextBottom(String text) {
if (tvRightBottom != null) {
tvRightBottom.setVisibility(VISIBLE);
tvRightBottom.setText(text);
}
}
public void setTvRightText(int text) {
if (tvRight != null) {
tvRight.setVisibility(VISIBLE);
tvRight.setText(text);
}
}
public void setTvRightOnClickListener(OnClickListener listener) {
tvRight.setOnClickListener(listener);
}
public void setTvRightBottomOnClickListener(OnClickListener listener) {
tvRightBottom.setOnClickListener(listener);
}
public void setIvLeftIcon(int resId) {
if (ivLeft != null) {
ivLeft.setVisibility(VISIBLE);
ivLeft.setImageResource(resId);
}
}
public void setIvLeftIcon(Drawable drawable) {
if (ivLeft != null) {
ivLeft.setVisibility(VISIBLE);
ivLeft.setImageDrawable(drawable);
}
}
public void setIvLeftOnClickListener(OnClickListener listener) {
ivLeft.setOnClickListener(listener);
}
}

@ -9,7 +9,71 @@
<include
android:id="@+id/toolbarView"
layout="@layout/layout_base" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_workTicket"
android:layout_width="0dp"
android:layout_height="40dp"
android:background="#cccccc"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_workTicket"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/colorPrimary"
android:gravity="center"
android:paddingEnd="20dp"
android:textSize="16sp"
android:text="工作票"/>
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#aaaaaa" />
<LinearLayout
android:id="@+id/ll_assiting"
android:layout_width="0dp"
android:layout_height="40dp"
android:background="#cccccc"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_assiting"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/colorPrimary"
android:gravity="center"
android:textSize="16sp"
android:text="辅助工作"/>
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#aaaaaa" />
<LinearLayout
android:id="@+id/ll_custom_add"
android:layout_width="0dp"
android:layout_height="40dp"
android:background="#cccccc"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_custom_add"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/colorPrimary"
android:gravity="center"
android:textSize="16sp"
android:text="手动添加"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -318,7 +382,7 @@
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#524658" />
android:background="#aaaaaa" />
<LinearLayout
android:id="@+id/ll_refresh"
android:layout_width="0dp"

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.activity.WorkTickerAssistantSelectListActivity">
<include
android:id="@+id/toolbarView"
layout="@layout/layout_base" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#dddddd"
android:padding="5dp"
android:minHeight="30px">
<TextView
android:id="@+id/tv_zxsj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5px"
android:gravity="center"
android:minHeight="50px"
android:text="作业风险清单日期:"
android:textSize="24px" />
<TextView
android:id="@+id/tv_st"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5px"
android:layout_weight="1"
android:gravity="center_vertical"
android:minHeight="50px"
android:textColor="@color/colorPrimaryDark"
android:text=""
android:textSize="24px" />
</LinearLayout>
<include
android:id="@+id/item_head"
layout="@layout/header_work_ticket_select_list"
android:layout_width="match_parent"
android:layout_marginStart="10px"
android:layout_marginEnd="10px"
android:layout_marginTop="5dp"
android:layout_height="wrap_content" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10px"
android:layout_marginEnd="10px"
android:layout_marginBottom="10px"
android:layout_weight="1">
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:dividerHeight="0px"/>
<TextView
android:id="@+id/tv_nodata"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/viewfinder_mask"
android:gravity="center"
android:text="暂无数据"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimary"
android:orientation="vertical">
<TextView
android:id="@+id/tv_submit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/white"
android:gravity="center"
android:textSize="18sp"
android:text="提交"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,14 @@
<?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/top_ll"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.rehome.zhdcoa.weiget.OAToolbarTwo
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100px"
android:background="@color/colorPrimaryDark" />
</LinearLayout>

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/iv_left"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="5dp"
android:background="#00ffffff"
android:contentDescription="back_btn_my_mt"
android:visibility="gone" />
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/tv_right"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:gravity="center|end"
android:text="工作票"
android:textColor="@color/white"
android:textSize="18sp"
android:visibility="visible" />
<TextView
android:id="@+id/tv_rightBottom"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:gravity="center|end"
android:text="辅助工作票"
android:textColor="@color/white"
android:textSize="18sp"
android:visibility="visible" />
</LinearLayout>
</RelativeLayout>
Loading…
Cancel
Save