手动添加作业风险信息 更新接口完成部分

master
wenfei 4 months ago
parent d2f309fb45
commit 7e85c90124

@ -49,13 +49,13 @@ public class WorkTickerCustomListAdapter extends BaseViewBindingAdapter<AdapterW
if(!TextUtils.isEmpty(item.getMajor())){ if(!TextUtils.isEmpty(item.getMajor())){
binding.tvZy.setText(item.getMajor()); binding.tvZy.setText(item.getMajor());
} }
binding.cb.setChecked(item.isChecked()); // binding.cb.setChecked(item.isChecked());
binding.cb.setOnClickListener(new View.OnClickListener() { // binding.cb.setOnClickListener(new View.OnClickListener() {
@Override // @Override
public void onClick(View view) { // public void onClick(View view) {
mCallBack.Click(view,position); // mCallBack.Click(view,position);
} // }
}); // });
binding.tvModify.setOnClickListener(new View.OnClickListener() { binding.tvModify.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -71,21 +71,21 @@ public class WorkTickerCustomListAdapter extends BaseViewBindingAdapter<AdapterW
int color = ContextCompat.getColor(context, R.color.colorPrimary); int color = ContextCompat.getColor(context, R.color.colorPrimary);
int colorRed = ContextCompat.getColor(context, R.color.red); int colorRed = ContextCompat.getColor(context, R.color.red);
if(TextUtils.isEmpty(item.getJobNo())){ if(TextUtils.isEmpty(item.getJobNo())){
binding.cb.setEnabled(true); //binding.cb.setEnabled(true);
binding.tvModify.setEnabled(true); binding.tvModify.setEnabled(true);
binding.tvDelete.setEnabled(true); binding.tvDelete.setEnabled(true);
binding.llModify.setBackgroundColor(color); binding.llModify.setBackgroundColor(color);
binding.llDelete.setBackgroundColor(colorRed); binding.llDelete.setBackgroundColor(colorRed);
}else{ }else{
if(item.getJobNo().equals(App.getInstance().getUserInfo().getManid())){ if(item.getJobNo().equals(App.getInstance().getUserInfo().getManid())){
binding.cb.setEnabled(true); //binding.cb.setEnabled(true);
binding.tvModify.setEnabled(true); binding.tvModify.setEnabled(true);
binding.tvDelete.setEnabled(true); binding.tvDelete.setEnabled(true);
binding.llModify.setBackgroundColor(color); binding.llModify.setBackgroundColor(color);
binding.llDelete.setBackgroundColor(colorRed); binding.llDelete.setBackgroundColor(colorRed);
}else{ }else{
//不是本人选中的,不允许修改 //不是本人选中的,不允许修改
binding.cb.setEnabled(false); //binding.cb.setEnabled(false);
binding.tvPaiHao.setTextColor(Color.GRAY); binding.tvPaiHao.setTextColor(Color.GRAY);
binding.tvContent.setTextColor(Color.GRAY); binding.tvContent.setTextColor(Color.GRAY);
binding.tvLevel.setTextColor(Color.GRAY); binding.tvLevel.setTextColor(Color.GRAY);

@ -41,6 +41,10 @@ public class WorkRiskLevelListBean extends AIBaseBean{
private List<HazardListBean> hazardList; private List<HazardListBean> hazardList;
//工单编号 //工单编号
private String orderNo; private String orderNo;
//开始时间yyyy-MM-dd HH:mm
private String startTime;
//结束时间yyyy-MM-dd HH:mm
private String endTime;
private boolean checked;//0:未选中,1:已选中 private boolean checked;//0:未选中,1:已选中
public String getCode() { public String getCode() {
@ -138,5 +142,21 @@ public class WorkRiskLevelListBean extends AIBaseBean{
public void setOrderNo(String orderNo) { public void setOrderNo(String orderNo) {
this.orderNo = orderNo; this.orderNo = orderNo;
} }
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
} }
} }

@ -9,6 +9,8 @@ import android.widget.ArrayAdapter
import android.widget.CompoundButton import android.widget.CompoundButton
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.rehome.zhdcoa.App import com.rehome.zhdcoa.App
import com.rehome.zhdcoa.Contans import com.rehome.zhdcoa.Contans
import com.rehome.zhdcoa.adapter.WorkRiskListTipAdapter import com.rehome.zhdcoa.adapter.WorkRiskListTipAdapter
@ -71,6 +73,7 @@ class WorkTickerCustomAddActivity : BaseActivityOaToolbarViewBinding<ActivityWor
private lateinit var calendarEt: Calendar private lateinit var calendarEt: Calendar
private var isEdit = false private var isEdit = false
private lateinit var item:WorkRiskLevelListBean.RowsBean
//格式化日期的对象(转化成习惯的时间格式) //格式化日期的对象(转化成习惯的时间格式)
private val sdFormat = SimpleDateFormat("yyyy-MM-dd HH:mm") private val sdFormat = SimpleDateFormat("yyyy-MM-dd HH:mm")
@ -90,10 +93,13 @@ class WorkTickerCustomAddActivity : BaseActivityOaToolbarViewBinding<ActivityWor
} }
launcherResult = createActivityResultLauncher() launcherResult = createActivityResultLauncher()
isEdit = intent.getBooleanExtra("isEdit",false)
if(!isEdit){
resetToday() resetToday()
}
isEdit = intent.getBooleanExtra("isEdit",false)
adapter = ArrayAdapter(this, R.layout.simple_spinner_item, items) adapter = ArrayAdapter(this, R.layout.simple_spinner_item, items)
binding.spinnerZy.adapter = adapter binding.spinnerZy.adapter = adapter
@ -117,6 +123,88 @@ class WorkTickerCustomAddActivity : BaseActivityOaToolbarViewBinding<ActivityWor
}; };
binding.lv.adapter = mAdapterHazard binding.lv.adapter = mAdapterHazard
if(isEdit){
showLog("--------------------custom item--------------------------")
val gson = Gson()
val itemStr = intent.getStringExtra("item")!!
showLog(itemStr)
item = gson.fromJson(itemStr,object:TypeToken<WorkRiskLevelListBean.RowsBean>() {}.type)
showLog(GsonUtils.GsonString(item))
binding.etMs.setText(item.content)
val level:String = item.level
if("A" == level){
binding.rb1.isChecked = true
binding.rb2.isChecked = false
binding.rb3.isChecked = false
binding.rb4.isChecked = false
binding.rb5.isChecked = false
binding.rb6.isChecked = false
}
if("B" == level){
binding.rb1.isChecked = false
binding.rb2.isChecked = true
binding.rb3.isChecked = false
binding.rb4.isChecked = false
binding.rb5.isChecked = false
binding.rb6.isChecked = false
}
if("C1" == level){
binding.rb1.isChecked = false
binding.rb2.isChecked = false
binding.rb3.isChecked = true
binding.rb4.isChecked = false
binding.rb5.isChecked = false
binding.rb6.isChecked = false
}
if("C2" == level){
binding.rb1.isChecked = false
binding.rb2.isChecked = false
binding.rb3.isChecked = false
binding.rb4.isChecked = true
binding.rb5.isChecked = false
binding.rb6.isChecked = false
}
if("C3" == level){
binding.rb1.isChecked = false
binding.rb2.isChecked = false
binding.rb3.isChecked = false
binding.rb4.isChecked = false
binding.rb5.isChecked = true
binding.rb6.isChecked = false
}
if("低风险" == level){
binding.rb1.isChecked = false
binding.rb2.isChecked = false
binding.rb3.isChecked = false
binding.rb4.isChecked = false
binding.rb5.isChecked = false
binding.rb6.isChecked = true
}
initStartDateAndEndDate()
if(item.hazardList!=null&&item.hazardList.size>0){
workRiskLevelTipListBeanList.clear()
for(itemHazard in item.hazardList){
if(itemHazard.precautionList.size>0){
for(itemPrecaution in itemHazard.precautionList){
val workRiskLevelTipListBean = WorkRiskLevelTipListBean()
workRiskLevelTipListBean.type=itemHazard.type
workRiskLevelTipListBean.precaution = itemPrecaution
workRiskLevelTipListBeanList.add(workRiskLevelTipListBean)
}
}
}
mAdapterHazard.notifyDataSetChanged()
}
if(item.major!=null){
for (i in items.indices) {
val major = items[i]
if(major==item.major){
binding.spinnerZy.setSelection(i)
}
}
}
}
binding.tvSt.setOnClickListener(View.OnClickListener { view: View? -> binding.tvSt.setOnClickListener(View.OnClickListener { view: View? ->
@ -256,7 +344,7 @@ class WorkTickerCustomAddActivity : BaseActivityOaToolbarViewBinding<ActivityWor
} }
override fun initData() { override fun initData() {
authenticationLoginAI() //authenticationLoginAI()
} }
//创建一个ActivityResultLauncher //创建一个ActivityResultLauncher
@ -365,6 +453,30 @@ class WorkTickerCustomAddActivity : BaseActivityOaToolbarViewBinding<ActivityWor
binding.tvEt.text = endDateStr binding.tvEt.text = endDateStr
} }
private fun initStartDateAndEndDate(){
try {
val dateSt = sdFormat.parse(item.startTime)
val calendarStartTime = Calendar.getInstance()
if(dateSt!=null){
calendarStartTime.setTime(dateSt)
//开始时间
calendarSt = calendarStartTime
binding.tvSt.text = item.startTime
}
val dateEt = sdFormat.parse(item.endTime)
val calendarEndTime = Calendar.getInstance()
if(dateEt!=null){
calendarEndTime.setTime(dateEt)
//结束时间
calendarEt = calendarEndTime
binding.tvEt.text = item.endTime
}
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
private fun authenticationLoginAISubmit() { private fun authenticationLoginAISubmit() {
try { try {
//AI三维登录接口 //AI三维登录接口

@ -109,23 +109,23 @@ class WorkTickerCustomListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
binding.lv.emptyView = binding.tvNodata binding.lv.emptyView = binding.tvNodata
//headView = View.inflate(this, R.layout.header_work_ticket_select_list, null) //headView = View.inflate(this, R.layout.header_work_ticket_select_list, null)
//cb = headView.findViewById<View>(R.id.cb) as CheckBox //cb = headView.findViewById<View>(R.id.cb) as CheckBox
binding.itemHead.cb.setOnClickListener { // binding.itemHead.cb.setOnClickListener {
if (binding.itemHead.cb.isChecked) { // if (binding.itemHead.cb.isChecked) {
for (i in datas.indices) { // for (i in datas.indices) {
datas[i].isChecked = true // datas[i].isChecked = true
mAdapter.notifyDataSetChanged() // mAdapter.notifyDataSetChanged()
} // }
deleteIdList.clear() // deleteIdList.clear()
} else { // } else {
for (i in datas.indices) { // for (i in datas.indices) {
datas[i].isChecked = false // datas[i].isChecked = false
mAdapter.notifyDataSetChanged() // mAdapter.notifyDataSetChanged()
} // }
if(selectList.size>0){ // if(selectList.size>0){
deleteIdList.addAll(selectList) // deleteIdList.addAll(selectList)
} // }
} // }
} // }
mAdapter = WorkTickerCustomListAdapter(this,datas,{ view, position -> mAdapter = WorkTickerCustomListAdapter(this,datas,{ view, position ->
val checkBox = view as CheckBox val checkBox = view as CheckBox
@ -147,17 +147,22 @@ class WorkTickerCustomListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
} }
} }
} }
binding.itemHead.cb.isChecked = count == datas.size //binding.itemHead.cb.isChecked = count == datas.size
mAdapter.notifyDataSetChanged() mAdapter.notifyDataSetChanged()
},{ position -> },{ position ->
val item:WorkRiskLevelListBean.RowsBean = datas[position] val item:WorkRiskLevelListBean.RowsBean = datas[position]
//showToast("修改") //showToast("修改")
val intent = Intent(context, WorkTickerCustomAddActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("isEdit", true)
intent.putExtra("item", GsonUtils.GsonString(item))
startActivity(intent)
},{ position -> },{ position ->
val item:WorkRiskLevelListBean.RowsBean = datas[position] val item:WorkRiskLevelListBean.RowsBean = datas[position]
//showToast("删除") //showToast("删除")
val dialog = CommitDialog(context, object : CommitDialogListener { val dialog = CommitDialog(context, object : CommitDialogListener {
override fun confirm() { override fun confirm() {
//authenticationLoginAISubmit() authenticationLoginAIDelete(item.id)
} }
override fun cancel() { override fun cancel() {
@ -332,6 +337,29 @@ class WorkTickerCustomListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
} }
} }
private fun authenticationLoginAIDelete(id:Int) {
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 {
deleteWorkTicketData(id)
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun getSubmitJsonData(): String { private fun getSubmitJsonData(): String {
val param = HashMap<String, Any>() val param = HashMap<String, Any>()
param["assignmentDate"] = binding.tvSt.text.toString().trim() param["assignmentDate"] = binding.tvSt.text.toString().trim()
@ -345,6 +373,15 @@ class WorkTickerCustomListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
return json return json
} }
private fun getDeleteJsonData(id:Int): String {
val param = HashMap<String, Any>()
param["id"] = id
val json = GsonUtils.GsonString(param)
showLog(json)
return json
}
private fun submitWorkTicketData() { private fun submitWorkTicketData() {
val url = Contans.BASE_URL_AI_3D_SERVER + Contans.DAYLY_RISK_LIST_SUBMIT_WORK_TICKET_LIST val url = Contans.BASE_URL_AI_3D_SERVER + Contans.DAYLY_RISK_LIST_SUBMIT_WORK_TICKET_LIST
val request = NoHttp.createStringRequest( val request = NoHttp.createStringRequest(
@ -393,17 +430,62 @@ class WorkTickerCustomListActivity : BaseActivityOaToolbarViewBinding<ActivityWo
}) })
} }
private fun deleteWorkTicketData(id:Int) {
val url = Contans.BASE_URL_AI_3D_SERVER + Contans.DAYLY_DELETE_CUSTOM_WORK_TICKET
val request = NoHttp.createStringRequest(
url,
RequestMethod.POST
)
val json: String = getDeleteJsonData(id)
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 }
}
} }
//class WorkTickerCustomListActivity : AppCompatActivity() { NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState) override fun onSucceed(what: Int, response: Response<String?>?) {
// enableEdgeToEdge() val result = response?.get()
// setContentView(R.layout.activity_work_ticker_custom_list) showLog("--------删除手动添加的作业风险信息成功--------")
// ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> showLog(url)
// val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) showLog(result)
// v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) val bean = GsonUtils.GsonToBean(
// insets result,
// } AIBaseBean::class.java
// } )
//} if (bean != null && bean.isSuccess) {
if(datas.size>0){
for(item in datas){
if(item.id==id){
datas.remove(item)
}
}
}
mAdapter.notifyDataSetChanged()
//提交成功
val confirmDialog = ConfirmDialog(
context, "删除手动添加的作业风险信息成功"
) {
}
confirmDialog.setTvTitle("提示")
confirmDialog.setCancelable(true)
confirmDialog.show()
}else{
showToast("删除手动添加的作业风险信息失败")
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
}
})
}
}

@ -74,6 +74,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="50dp"
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
android:visibility="gone"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/tv_submit" android:id="@+id/tv_submit"

@ -24,24 +24,24 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#524658" /> android:background="#524658" />
<LinearLayout <!-- <LinearLayout-->
android:layout_width="0dp" <!-- android:layout_width="0dp"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:layout_gravity="center" <!-- android:layout_gravity="center"-->
android:layout_weight="0.5" <!-- android:layout_weight="0.5"-->
android:gravity="center"> <!-- android:gravity="center">-->
<CheckBox <!-- <CheckBox-->
android:id="@+id/cb" <!-- android:id="@+id/cb"-->
android:layout_width="wrap_content" <!-- android:layout_width="wrap_content"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:focusable="false" /> <!-- android:focusable="false" />-->
</LinearLayout> <!-- </LinearLayout>-->
<View <!-- <View-->
android:layout_width="1dp" <!-- android:layout_width="1dp"-->
android:layout_height="match_parent" <!-- android:layout_height="match_parent"-->
android:background="#524658" /> <!-- android:background="#524658" />-->
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"

@ -18,25 +18,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60px"> android:minHeight="60px">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#524658" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:gravity="center">
<CheckBox
android:id="@+id/cb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false" />
</LinearLayout>
<View <View
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"

Loading…
Cancel
Save