package com.shxy.i2.Tool; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.XML; import com.shxy.i2.bean.SendDataBean; import com.shxy.i2.constant.CommonStatus; import com.shxy.i2.constant.Constant; import com.shxy.i2.dao.*; import lombok.extern.slf4j.Slf4j; import org.apache.cxf.endpoint.Client; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import java.math.BigInteger; import java.util.ArrayList; import java.util.Date; import java.util.List; @Slf4j @Component public class AsyncMethod { @Autowired private Data_Dlq_JbfdDao data_dlq_jbfdDao; @Autowired private Data_Byq_JbfdDao data_byq_jbfdDao; @Autowired private Data_SF6_QtylDao data_sf6_qtylDao; @Autowired private Data_YspDao data_yspDao; @Autowired private Data_WsDao data_wsDao; @Autowired private Data_TxDao data_txDao; @Autowired private Data_DcywDao data_dcywDao; @Autowired private Data_Dr_JyjcDao data_dr_jyjcDao; @Autowired private Data_Jsyhw_JyjcDao data_jsyhw_jyjcDao; @Autowired private Data_FhzxqDao data_fhzxqDao; @Autowired private Data_FhdlbxDao data_fhdlbxDao; @Autowired private Data_SF6_QtsfDao data_sf6_qtsfDao; @Autowired private Data_MicroclimateDao data_microclimateDao; @Autowired private Data_CnjDao data_cnjDao; @Async(value = "asyncServiceExecutor") public void sendData(Client client, List idlist, String xml, String type) throws Exception { Object[] objects = client.invoke("uploadCACData", xml); String threadId = Thread.currentThread().getName(); log.info("线程序号: " + threadId + "当前时间:" + new Date()); if (objects != null && objects.length > 0) { String string = String.valueOf(objects[0]); log.info("返回的长度 : " + objects.length + " 返回的对象 : " + string); JSONObject jsonObject = XML.toJSONObject(string); if (jsonObject != null) { JSONObject response = (JSONObject) jsonObject.get("response"); if (response != null) { JSONObject result = (JSONObject) response.get("result"); if (result != null) { Integer code = (Integer) result.get("code"); if (code != null && code.intValue() == 0) { log.info("上传成功"); log.info("修改的id: " + idlist.toString()); if (CollectionUtil.isNotEmpty(idlist)) { if (StrUtil.equals(type, Constant.SF6_QTYL)) { data_sf6_qtylDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.BYQ_JBFD)) { data_byq_jbfdDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.DLQJBFD)) { data_dlq_jbfdDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.YSP)) { data_yspDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.WS)) { data_wsDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.TX)) { data_txDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.DCYW)) { data_dcywDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.DRJYJC)) { data_dr_jyjcDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.JSYHW)) { data_jsyhw_jyjcDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.FHZXQ)) { data_fhzxqDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.FHDLBX)) { data_fhdlbxDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.CNJ)) { data_cnjDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.SF6_QTSF)) { data_sf6_qtsfDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.WQX)) { data_microclimateDao.updateList(CommonStatus.UPLOAD.value(), idlist, new Date()); } } } else { log.info("上传失败"); } } } } } } @Async(value = "asyncServiceExecutor") public void sendJBFDData(Client client, ArrayList idlist, String xml, String type) throws Exception { Object[] objects = client.invoke("uploadCACData", xml); String threadId = Thread.currentThread().getName(); log.info("线程序号: " + threadId + "当前时间:" + new Date()); // log.info("上传的数据: " + xml); if (objects != null && objects.length > 0) { String string = String.valueOf(objects[0]); log.info("返回的长度 : " + objects.length + " 返回的对象 : " + string); JSONObject jsonObject = XML.toJSONObject(string); if (jsonObject != null) { JSONObject response = (JSONObject) jsonObject.get("response"); if (response != null) { JSONObject result = (JSONObject) response.get("result"); if (result != null) { Integer code = (Integer) result.get("code"); if (code != null && code.intValue() == 0) { log.info("上传成功"); log.info("修改的id: " + idlist.toString()); if (CollectionUtil.isNotEmpty(idlist)) { if (StrUtil.equals(type, Constant.BYQ_JBFD)) { data_byq_jbfdDao.updateDataList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.DLQJBFD)) { data_dlq_jbfdDao.updateDataList(CommonStatus.UPLOAD.value(), idlist, new Date()); } else if (StrUtil.equals(type, Constant.YSP)) { data_yspDao.updateDataList(CommonStatus.UPLOAD.value(), idlist, new Date()); } } } else { log.info("上传失败"); } } } } } } @Async(value = "asyncServiceExecutor") public void sendJBFDData2(Client client, BigInteger maxid, ArrayList list1, String xml, String type) throws Exception { Object[] objects = client.invoke("uploadCACData", xml); String threadId = Thread.currentThread().getName(); log.info("线程序号: " + threadId + "当前时间:" + new Date()); // log.info("上传的数据: " + xml); if (objects != null && objects.length > 0) { String string = String.valueOf(objects[0]); log.info("返回的长度 : " + objects.length + " 返回的对象 : " + string); JSONObject jsonObject = XML.toJSONObject(string); if (jsonObject != null) { JSONObject response = (JSONObject) jsonObject.get("response"); if (response != null) { JSONObject result = (JSONObject) response.get("result"); if (result != null) { Integer code = (Integer) result.get("code"); if (code != null && code.intValue() == 0) { log.info("上传成功"); log.info("修改的id: " + list1.toString()); if (CollectionUtil.isNotEmpty(list1)) { if (StrUtil.equals(type, Constant.BYQ_JBFD)) { data_byq_jbfdDao.updateDataList2(CommonStatus.UPLOAD.value(), maxid,list1, new Date()); } else if (StrUtil.equals(type, Constant.DLQJBFD)) { data_dlq_jbfdDao.updateDataList2(CommonStatus.UPLOAD.value(),maxid, list1, new Date()); } else if (StrUtil.equals(type, Constant.YSP)) { data_yspDao.updateDataList2(CommonStatus.UPLOAD.value(), maxid, list1, new Date()); } } } else { log.info("上传失败"); } } } } } } }