|
@@ -9,7 +9,10 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.core.page.TableSupport;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.sql.SqlUtil;
|
|
|
+import com.ruoyi.system.domain.dto.UserEnterpriseRelation;
|
|
|
+import com.ruoyi.web.controller.iot.OrderController;
|
|
|
import com.ruoyi.web.controller.iot.domain.*;
|
|
|
+import com.ruoyi.web.controller.iot.domain.DTO.CompanyDatabase;
|
|
|
import com.ruoyi.web.controller.iot.mapper.EnterpriseMapper;
|
|
|
import com.ruoyi.web.controller.iot.service.IOrderService;
|
|
|
import com.ruoyi.web.dataBase.DatabaseConnectionMap;
|
|
@@ -162,9 +165,9 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
if (!ObjectUtils.isEmpty(device.getModel())) {
|
|
|
condition += "and equipment_code like '%" + device.getModel() + "%'";
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(device.getEnterpriseName())) {
|
|
|
- condition += "and order_status = " + device.getEnterpriseName();
|
|
|
- }
|
|
|
+// if (!ObjectUtils.isEmpty(device.getEnterpriseName())) {
|
|
|
+// condition += "and order_status = " + device.getEnterpriseName();
|
|
|
+// }
|
|
|
if (!ObjectUtils.isEmpty(device.getConnectionTimeList()) && device.getConnectionTimeList().size() > 0) {
|
|
|
condition += "and equipment_code >= '" + device.getConnectionTimeList().get(0) + "'";
|
|
|
condition += "and equipment_code <= '" + device.getConnectionTimeList().get(1) + "'";
|
|
@@ -172,11 +175,28 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
try {
|
|
|
|
|
|
Map<String, JdbcTemplate> jdbcTemplateMap = databaseConnectionMap.getJdbcTemplate();
|
|
|
- Set<String> key = jdbcTemplateMap.keySet();
|
|
|
+ JdbcTemplate iotDataBast = DatabaseConnectionMap.getIOT_DATA_BAST();
|
|
|
|
|
|
- for (String keyUrl : key) {
|
|
|
- JdbcTemplate template = jdbcTemplateMap.get(keyUrl);
|
|
|
- List<Device> deviceList = template.query("SELECT ie.* ,it.tsl_name as tslName, '" + keyUrl + "' as url" + " FROM iot_equipment ie " +
|
|
|
+ String sql = "select ue.enterprise_name as companyName, ue.enterprise_database_url as companyDataBaseUrl from t_sys_enterprise ue inner join user_enterprise_relation uer on ue.enterprise_openid = uer.enterprise_open_id where ue.factory_status = 1 and uer.standing_id = " + SecurityUtils.getLoginUser().getUser().getDeptId();
|
|
|
+
|
|
|
+ List<CompanyDatabase> companyDatabaseList = iotDataBast.query(sql, new BeanPropertyRowMapper<>(CompanyDatabase.class));
|
|
|
+
|
|
|
+ for (CompanyDatabase companyDataba : companyDatabaseList) {
|
|
|
+ String requestEnterpriseName = device.getEnterpriseName();
|
|
|
+ if (requestEnterpriseName != null && !requestEnterpriseName.isEmpty()) {
|
|
|
+ if (!companyDataba.getCompanyName().contains(requestEnterpriseName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JdbcTemplate template = jdbcTemplateMap.get(companyDataba.getCompanyDataBaseUrl());
|
|
|
+ String companyData = ", '" + companyDataba.getCompanyName() + "' as enterpriseName";
|
|
|
+
|
|
|
+
|
|
|
+// for (String keyUrl : key) {
|
|
|
+// JdbcTemplate template = jdbcTemplateMap.get(keyUrl);
|
|
|
+ String keyUrl = companyDataba.getCompanyDataBaseUrl();
|
|
|
+ List<Device> deviceList = template.query("SELECT ie.* ,it.tsl_name as tslName, '" + keyUrl + "' as url" + companyData + " FROM iot_equipment ie " +
|
|
|
"LEFT JOIN iot_tsl it ON ie.tsl_id = it.id " +
|
|
|
" where 1=1 " + (ObjectUtils.isEmpty(condition) ? "" : condition) + ";",
|
|
|
new BeanPropertyRowMapper<Device>(Device.class));
|
|
@@ -646,6 +666,67 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public TableDataInfo alarmLoggingList(AlarmLogging alarmLogging) {
|
|
|
+ List<AlarmLogging> orderList = new ArrayList<>();
|
|
|
+ PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
+ Integer pageNum = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
|
|
|
+ Integer pageSize = pageDomain.getPageSize();
|
|
|
+ String condition = "";
|
|
|
+ if (!ObjectUtils.isEmpty(alarmLogging.getEquipmentName())) {
|
|
|
+ condition += "and equipment_name like '%" + alarmLogging.getEquipmentName() + "%'";
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(alarmLogging.getEquipmentCode())) {
|
|
|
+ condition += "and equipment_code like '%" + alarmLogging.getEquipmentCode() + "%'";
|
|
|
+ }
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<String, JdbcTemplate> jdbcTemplateMap = databaseConnectionMap.getJdbcTemplate();
|
|
|
+
|
|
|
+ JdbcTemplate iotDataBast = DatabaseConnectionMap.getIOT_DATA_BAST();
|
|
|
+
|
|
|
+ String sql = "select ue.enterprise_name as companyName, ue.enterprise_database_url as companyDataBaseUrl from t_sys_enterprise ue inner join user_enterprise_relation uer on ue.enterprise_openid = uer.enterprise_open_id where ue.factory_status = 1 and uer.standing_id = " + SecurityUtils.getLoginUser().getUser().getDeptId();
|
|
|
+
|
|
|
+ List<CompanyDatabase> companyDatabaseList = iotDataBast.query(sql, new BeanPropertyRowMapper<>(CompanyDatabase.class));
|
|
|
+
|
|
|
+ for (CompanyDatabase companyDataba : companyDatabaseList) {
|
|
|
+ String requestEnterpriseName = alarmLogging.getEnterpriseName();
|
|
|
+ if (requestEnterpriseName != null && !requestEnterpriseName.isEmpty()) {
|
|
|
+ if (!companyDataba.getCompanyName().contains(requestEnterpriseName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String creditCode = "";
|
|
|
+ String jsonString = executeGet(url + companyDataba.getCompanyName(), token);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
|
+ if ("0".equals(jsonObject.getString("error_code"))) {
|
|
|
+ String result = jsonObject.getString("result");
|
|
|
+ JSONObject jsonData = JSONObject.parseObject(result);
|
|
|
+ creditCode = jsonData.getString("creditCode");
|
|
|
+ }
|
|
|
+
|
|
|
+ JdbcTemplate template = jdbcTemplateMap.get(companyDataba.getCompanyDataBaseUrl());
|
|
|
+ String companyData = ", '" + companyDataba.getCompanyName() + "' as enterpriseName";
|
|
|
+ String creditCodeSql = ", '" + creditCode + "' as enterpriseCode";
|
|
|
+
|
|
|
+ List<AlarmLogging> deviceList = template.query("SELECT ie.* ,it.tsl_name as tslName " + companyData + creditCodeSql + " FROM iot_equipment ie " +
|
|
|
+ "LEFT JOIN iot_tsl it ON ie.tsl_id = it.id " +
|
|
|
+ " where 1=1 " + (ObjectUtils.isEmpty(condition) ? "" : condition) + ";",
|
|
|
+ new BeanPropertyRowMapper<AlarmLogging>(AlarmLogging.class));
|
|
|
+ orderList.addAll(deviceList);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e.getMessage());
|
|
|
+ }
|
|
|
+ TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
+ tableDataInfo.setCode(HttpStatus.SUCCESS);
|
|
|
+ tableDataInfo.setMsg("查询成功");
|
|
|
+ tableDataInfo.setRows(orderList.stream().skip(pageNum).limit(pageSize).collect(Collectors.toList()));
|
|
|
+ tableDataInfo.setTotal(orderList.size());
|
|
|
+ return tableDataInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public AjaxResult deviceDetails(Device device) {
|
|
|
List<IotRealData> iotRealDataList = new ArrayList<>();
|
|
|
try {
|