|
|
@@ -1,17 +1,19 @@
|
|
|
package com.ruoyi.web.controller.iot.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.ruoyi.common.constant.HttpStatus;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.PageDomain;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.core.page.TableSupport;
|
|
|
-import com.ruoyi.common.utils.SecurityUtils;
|
|
|
-import com.ruoyi.web.controller.iot.domain.Device;
|
|
|
-import com.ruoyi.web.controller.iot.domain.Order;
|
|
|
-import com.ruoyi.web.controller.iot.domain.ProductOrder;
|
|
|
-import com.ruoyi.web.controller.iot.domain.TransportOrder;
|
|
|
+import com.ruoyi.web.controller.iot.domain.*;
|
|
|
import com.ruoyi.web.controller.iot.service.IOrderService;
|
|
|
import com.ruoyi.web.dataBase.DatabaseConnectionMap;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
@@ -22,6 +24,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author :jixinyuan
|
|
|
@@ -34,6 +37,9 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
@Autowired
|
|
|
private DatabaseConnectionMap databaseConnectionMap;
|
|
|
|
|
|
+ private static String url = "http://open.api.tianyancha.com/services/open/cb/ic/2.0?keyword=";
|
|
|
+ private static String token = "55b0db34-2573-48f3-bc40-ef2db0077606";
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo list(Order order) {
|
|
|
List<Order> orderList = new ArrayList<>();
|
|
|
@@ -68,45 +74,36 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
if (!ObjectUtils.isEmpty(order.getEndTime())) {
|
|
|
condition += "and fo.end_time <= '" + order.getEndTime() + "'";
|
|
|
}
|
|
|
- Integer count = 0;
|
|
|
try {
|
|
|
List<JdbcTemplate> jdbcTemplate = databaseConnectionMap.getJdbcTemplate();
|
|
|
- JdbcTemplate template = jdbcTemplate.get(0);
|
|
|
-// DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
|
|
-// dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
|
|
-// dataSource.setUrl("jdbc:mysql://47.94.195.4:3525/boyo_fb4a88d6f6f24d67953f68c4fe829f63?useUnicode=true&useSSL=false&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai");
|
|
|
-// dataSource.setUsername("db_cdyq6tkqn1ioja179i8b");
|
|
|
-// dataSource.setPassword("By@#5c9i75sgtx3b620g6m6e");
|
|
|
-// JdbcTemplate template = new JdbcTemplate(dataSource);
|
|
|
- orderList = template.query("SELECT fo.*,tto.shipping_status as status FROM t_factory_order fo left join t_transport_order tto on fo.order_num = tto.order_num where 1=1 "
|
|
|
- + (ObjectUtils.isEmpty(condition) ? "" : condition)
|
|
|
- + " limit " + pageNum + "," + pageSize + ";" ,
|
|
|
- new BeanPropertyRowMapper<Order>(Order.class));
|
|
|
- for (Order item : orderList) {
|
|
|
- if (item.getOrderStatus().equals(1)) {
|
|
|
- item.setStatus("生产中");
|
|
|
- }
|
|
|
- if ("1".equals(item.getStatus())) {
|
|
|
- item.setStatus("已发货");
|
|
|
- }
|
|
|
- if ("2".equals(item.getStatus())) {
|
|
|
- item.setStatus("已签收");
|
|
|
- }
|
|
|
- if (item.getOverdue().contains("逾期")) {
|
|
|
- item.setStatus("已逾期");
|
|
|
+ for (JdbcTemplate template : jdbcTemplate) {
|
|
|
+ List<Order> orders = template.query("SELECT fo.*,tto.shipping_status as status FROM t_factory_order fo left join t_transport_order tto on fo.order_num = tto.order_num where 1=1 "
|
|
|
+ + (ObjectUtils.isEmpty(condition) ? "" : condition) + ";",
|
|
|
+ new BeanPropertyRowMapper<Order>(Order.class));
|
|
|
+ for (Order item : orders) {
|
|
|
+ if (item.getOrderStatus().equals(1)) {
|
|
|
+ item.setStatus("生产中");
|
|
|
+ }
|
|
|
+ if ("1".equals(item.getStatus())) {
|
|
|
+ item.setStatus("已发货");
|
|
|
+ }
|
|
|
+ if ("2".equals(item.getStatus())) {
|
|
|
+ item.setStatus("已签收");
|
|
|
+ }
|
|
|
+ if (item.getOverdue().contains("逾期")) {
|
|
|
+ item.setStatus("已逾期");
|
|
|
+ }
|
|
|
}
|
|
|
+ orderList.addAll(orders);
|
|
|
}
|
|
|
- count = template.queryForObject("SELECT count(fo.id) FROM t_factory_order fo " +
|
|
|
- "left join t_transport_order tto on fo.order_num = tto.order_num " +
|
|
|
- "where 1=1 " + (ObjectUtils.isEmpty(condition) ? "" : condition)+";" , Integer.class);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
tableDataInfo.setCode(HttpStatus.SUCCESS);
|
|
|
tableDataInfo.setMsg("查询成功");
|
|
|
- tableDataInfo.setRows(orderList);
|
|
|
- tableDataInfo.setTotal(count);
|
|
|
+ tableDataInfo.setRows(orderList.stream().skip(pageNum).limit(pageSize).collect(Collectors.toList()));
|
|
|
+ tableDataInfo.setTotal(orderList.size());
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
@@ -116,22 +113,16 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
try {
|
|
|
List<JdbcTemplate> jdbcTemplate = databaseConnectionMap.getJdbcTemplate();
|
|
|
JdbcTemplate template = jdbcTemplate.get(0);
|
|
|
-// DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
|
|
-// dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
|
|
-// dataSource.setUrl("jdbc:mysql://47.94.195.4:3525/boyo_fb4a88d6f6f24d67953f68c4fe829f63?useUnicode=true&useSSL=false&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai");
|
|
|
-// dataSource.setUsername("db_cdyq6tkqn1ioja179i8b");
|
|
|
-// dataSource.setPassword("By@#5c9i75sgtx3b620g6m6e");
|
|
|
-// JdbcTemplate template = new JdbcTemplate(dataSource);
|
|
|
- detail = template.queryForObject("SELECT * FROM t_factory_order where id = " + order.getId() + ";" , new BeanPropertyRowMapper<Order>(Order.class));
|
|
|
+ detail = template.queryForObject("SELECT * FROM t_factory_order where id = " + order.getId() + ";", new BeanPropertyRowMapper<Order>(Order.class));
|
|
|
if (!ObjectUtils.isEmpty(detail)) {
|
|
|
- List<ProductOrder> productOrderList = template.query("SELECT pod.* ,pp.process_name as processName FROM " +
|
|
|
+ List<ProductOrderDetail> productOrderDetailList = template.query("SELECT pod.* ,pp.process_name as processName FROM " +
|
|
|
"t_product_order_detail pod LEFT JOIN t_product_process pp ON pod.process_id = pp.id " +
|
|
|
- "WHERE order_id = " + detail.getId() + ";" ,
|
|
|
- new BeanPropertyRowMapper<ProductOrder>(ProductOrder.class));
|
|
|
- if (!ObjectUtils.isEmpty(productOrderList)) {
|
|
|
- detail.setProductOrderList(productOrderList);
|
|
|
+ "WHERE order_id = " + detail.getId() + ";",
|
|
|
+ new BeanPropertyRowMapper<ProductOrderDetail>(ProductOrderDetail.class));
|
|
|
+ if (!ObjectUtils.isEmpty(productOrderDetailList)) {
|
|
|
+ detail.setProductOrderDetailList(productOrderDetailList);
|
|
|
}
|
|
|
- List<TransportOrder> transportOrders = template.query("SELECT * FROM t_transport_order where order_num = '" + detail.getOrderNum() + "';" ,
|
|
|
+ List<TransportOrder> transportOrders = template.query("SELECT * FROM t_transport_order where order_num = '" + detail.getOrderNum() + "';",
|
|
|
new BeanPropertyRowMapper<TransportOrder>(TransportOrder.class));
|
|
|
if (!ObjectUtils.isEmpty(transportOrders) && transportOrders.size() > 0) {
|
|
|
detail.setTransportOrder(transportOrders.get(0));
|
|
|
@@ -166,70 +157,218 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
condition += "and equipment_code >= '" + device.getConnectionTimeList().get(0) + "'";
|
|
|
condition += "and equipment_code <= '" + device.getConnectionTimeList().get(1) + "'";
|
|
|
}
|
|
|
- Integer count = 0;
|
|
|
try {
|
|
|
List<JdbcTemplate> jdbcTemplate = databaseConnectionMap.getJdbcTemplate();
|
|
|
- JdbcTemplate template = jdbcTemplate.get(0);
|
|
|
-// DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
|
|
-// dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
|
|
-// dataSource.setUrl("jdbc:mysql://47.94.195.4:3525/boyo_fb4a88d6f6f24d67953f68c4fe829f63?useUnicode=true&useSSL=false&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai");
|
|
|
-// dataSource.setUsername("db_cdyq6tkqn1ioja179i8b");
|
|
|
-// dataSource.setPassword("By@#5c9i75sgtx3b620g6m6e");
|
|
|
-// JdbcTemplate template = new JdbcTemplate(dataSource);
|
|
|
- orderList = template.query("SELECT ie.* ,it.tsl_name as tslName FROM iot_equipment ie " +
|
|
|
- "LEFT JOIN iot_tsl it ON ie.tsl_id = it.id " +
|
|
|
- " where 1=1 " + (ObjectUtils.isEmpty(condition) ? "" : condition)
|
|
|
- + " limit " + pageNum + "," + pageSize + ";" ,
|
|
|
- new BeanPropertyRowMapper<Device>(Device.class));
|
|
|
-
|
|
|
- count = template.queryForObject("SELECT count(*) FROM iot_equipment ;" , Integer.class);
|
|
|
+ for (JdbcTemplate template : jdbcTemplate) {
|
|
|
+ List<Device> deviceList = template.query("SELECT ie.* ,it.tsl_name as tslName 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));
|
|
|
+ orderList.addAll(deviceList);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
tableDataInfo.setCode(HttpStatus.SUCCESS);
|
|
|
tableDataInfo.setMsg("查询成功");
|
|
|
- tableDataInfo.setRows(orderList);
|
|
|
- tableDataInfo.setTotal(count);
|
|
|
+ tableDataInfo.setRows(orderList.stream().skip(pageNum).limit(pageSize).collect(Collectors.toList()));
|
|
|
+ tableDataInfo.setTotal(orderList.size());
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult accounting() {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ int count0 = 0;
|
|
|
+ int count1 = 0;
|
|
|
+ int count2 = 0;
|
|
|
+ int count3 = 0;
|
|
|
+ int count4 = 0;
|
|
|
try {
|
|
|
List<JdbcTemplate> jdbcTemplate = databaseConnectionMap.getJdbcTemplate();
|
|
|
- JdbcTemplate template = jdbcTemplate.get(0);
|
|
|
-// DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
|
|
-// dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
|
|
-// dataSource.setUrl("jdbc:mysql://47.94.195.4:3525/boyo_fb4a88d6f6f24d67953f68c4fe829f63?useUnicode=true&useSSL=false&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai");
|
|
|
-// dataSource.setUsername("db_cdyq6tkqn1ioja179i8b");
|
|
|
-// dataSource.setPassword("By@#5c9i75sgtx3b620g6m6e");
|
|
|
-// JdbcTemplate template = new JdbcTemplate(dataSource);
|
|
|
- int count0 = template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
- "left join t_transport_order tto on fo.order_num = tto.order_num ;" , Integer.class);
|
|
|
- int count1 = template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
- "left join t_transport_order tto on fo.order_num = tto.order_num where fo.overdue like '%逾期%' ;" , Integer.class);
|
|
|
- int count2 = template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
- "left join t_transport_order tto on fo.order_num = tto.order_num where fo.order_status = 1 ;" , Integer.class);
|
|
|
- int count3 = template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
- "left join t_transport_order tto on fo.order_num = tto.order_num where tto.shipping_status = 1 ;" , Integer.class);
|
|
|
- int count4 = template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
- "left join t_transport_order tto on fo.order_num = tto.order_num where tto.shipping_status = 2 ;" , Integer.class);
|
|
|
- map.put("count0" , count0 + "");
|
|
|
- map.put("count1" , count1 + "");
|
|
|
- map.put("count2" , count2 + "");
|
|
|
- map.put("count3" , count3 + "");
|
|
|
- map.put("count4" , count4 + "");
|
|
|
+ for (JdbcTemplate template : jdbcTemplate) {
|
|
|
+ count0 += template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
+ "left join t_transport_order tto on fo.order_num = tto.order_num ;", Integer.class);
|
|
|
+ count1 += template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
+ "left join t_transport_order tto on fo.order_num = tto.order_num where fo.overdue like '%逾期%' ;", Integer.class);
|
|
|
+ count2 += template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
+ "left join t_transport_order tto on fo.order_num = tto.order_num where fo.order_status = 1 ;", Integer.class);
|
|
|
+ count3 += template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
+ "left join t_transport_order tto on fo.order_num = tto.order_num where tto.shipping_status = 1 ;", Integer.class);
|
|
|
+ count4 += template.queryForObject("SELECT count(*) as status FROM t_factory_order fo " +
|
|
|
+ "left join t_transport_order tto on fo.order_num = tto.order_num where tto.shipping_status = 2 ;", Integer.class);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
+ map.put("count0", count0 + "");
|
|
|
+ map.put("count1", count1 + "");
|
|
|
+ map.put("count2", count2 + "");
|
|
|
+ map.put("count3", count3 + "");
|
|
|
+ map.put("count4", count4 + "");
|
|
|
return AjaxResult.success(map);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AjaxResult deviceDetails(Device device) {
|
|
|
+ public TableDataInfo bankList(Order order) {
|
|
|
+ List<Order> orderList = new ArrayList<>();
|
|
|
+ PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
+ Integer pageNum = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
|
|
|
+ Integer pageSize = pageDomain.getPageSize();
|
|
|
+ String condition = "";
|
|
|
+ if (!ObjectUtils.isEmpty(order.getOrderNum())) {
|
|
|
+ condition += "and fo.order_num like '%" + order.getOrderNum() + "%'";
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(order.getOrderName())) {
|
|
|
+ condition += "and fo.order_name like '%" + order.getOrderName() + "%'";
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(order.getCustomerName())) {
|
|
|
+ condition += "and fo.customer_name like '%" + order.getCustomerName() + "%'";
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(order.getOrderStatus())) {
|
|
|
+ condition += "and fo.order_status =" + order.getOrderStatus();
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(order.getDeliveryCycle())) {
|
|
|
+ condition += "and fo.delivery_cycle = " + order.getDeliveryCycle();
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(order.getStartTime())) {
|
|
|
+ condition += "and fo.start_time >= '" + order.getStartTime() + "'";
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(order.getEndTime())) {
|
|
|
+ condition += "and fo.end_time <= '" + order.getEndTime() + "'";
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ List<JdbcTemplate> jdbcTemplate = databaseConnectionMap.getJdbcTemplate();
|
|
|
+ for (JdbcTemplate template : jdbcTemplate) {
|
|
|
+ List<Order> orders = template.query("SELECT fo.*,tto.shipping_status as status FROM t_factory_order fo left join t_transport_order tto on fo.order_num = tto.order_num where 1=1 "
|
|
|
+ + (ObjectUtils.isEmpty(condition) ? "" : condition) + ";",
|
|
|
+ new BeanPropertyRowMapper<Order>(Order.class));
|
|
|
+ for (Order item : orders) {
|
|
|
+ if (item.getOrderStatus().equals(1)) {
|
|
|
+ item.setStatus("生产中");
|
|
|
+ }
|
|
|
+ if ("1".equals(item.getStatus())) {
|
|
|
+ item.setStatus("已发货");
|
|
|
+ }
|
|
|
+ if ("2".equals(item.getStatus())) {
|
|
|
+ item.setStatus("已签收");
|
|
|
+ }
|
|
|
+ if (item.getOverdue().contains("逾期")) {
|
|
|
+ item.setStatus("已逾期");
|
|
|
+ }
|
|
|
+ String jsonString = executeGet(url + item.getCustomerName(), token);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
|
+ if ("0".equals(jsonObject.getString("error_code"))) {
|
|
|
+ String result = jsonObject.getString("result");
|
|
|
+ JSONObject jsonData = JSONObject.parseObject(result);
|
|
|
+ item.setEnterpriseName(jsonData.getString("name"));
|
|
|
+ item.setEnterpriseLegalPerson(jsonData.getString("legalPersonName"));
|
|
|
+ item.setContactInformation(jsonData.getString("phoneNumber"));
|
|
|
+ item.setEnterpriseType(jsonData.getString("industry"));
|
|
|
+ item.setDateEstablishment(jsonData.getString("estiblishTime"));
|
|
|
+ item.setRegisteredCapital(jsonData.getString("regCapital"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderList.addAll(orders);
|
|
|
+ }
|
|
|
+ } 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 bankDetails(Order order) {
|
|
|
+ Order detail = new Order();
|
|
|
+ try {
|
|
|
+ List<JdbcTemplate> jdbcTemplate = databaseConnectionMap.getJdbcTemplate();
|
|
|
+ JdbcTemplate template = jdbcTemplate.get(0);
|
|
|
+ detail = template.queryForObject("SELECT * FROM t_factory_order where id = " + order.getId() + ";", new BeanPropertyRowMapper<Order>(Order.class));
|
|
|
+ if (!ObjectUtils.isEmpty(detail)) {
|
|
|
+ List<ProductOrder> productOrderList = template.query("SELECT po.* ,pg.group_name as processGroupName FROM " +
|
|
|
+ "t_product_order po LEFT JOIN t_process_group pg ON po.process_group_id = pg.id " +
|
|
|
+ "WHERE po.task_id = " + detail.getId() + ";",
|
|
|
+ new BeanPropertyRowMapper<ProductOrder>(ProductOrder.class));
|
|
|
+ if (!ObjectUtils.isEmpty(productOrderList)) {
|
|
|
+ detail.setProductOrderList(productOrderList);
|
|
|
+ List<Material> materialList = new ArrayList<>();
|
|
|
+ for (ProductOrder item : productOrderList) {
|
|
|
+ List<Material> materials = template.query("SELECT * FROM t_material where id = "
|
|
|
+ + item.getProductionId() + ";",
|
|
|
+ new BeanPropertyRowMapper<Material>(Material.class));
|
|
|
+ if (!ObjectUtils.isEmpty(materials)) {
|
|
|
+ for (Material material : materials) {
|
|
|
+ material.setProductionNum(item.getProductionNum());
|
|
|
+ material.setDeliveryDate(item.getDeliveryDate());
|
|
|
+ }
|
|
|
+ materialList.addAll(materials);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detail.setMaterialList(materialList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e.getMessage());
|
|
|
+ }
|
|
|
+ return AjaxResult.success(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo enterpriseList(Order order) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AjaxResult deviceDetails(Device device) {
|
|
|
+ List<IotRealData> iotRealDataList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ List<JdbcTemplate> jdbcTemplate = databaseConnectionMap.getJdbcTemplate();
|
|
|
+ JdbcTemplate template = jdbcTemplate.get(0);
|
|
|
+ iotRealDataList = template.query("SELECT ird.*,ie.equipment_name AS deviceName," +
|
|
|
+ "ita.attr_name AS tagName " +
|
|
|
+ "FROM iot_real_data ird " +
|
|
|
+ "LEFT JOIN iot_equipment ie ON ird.device_code = ie.equipment_code " +
|
|
|
+ "LEFT JOIN iot_tsl_attr ita ON ird.tag = ita.attr_code " +
|
|
|
+ "where ird.device_code = '" + device.getEquipmentCode() + "';",
|
|
|
+ new BeanPropertyRowMapper<IotRealData>(IotRealData.class));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e.getMessage());
|
|
|
+ }
|
|
|
+ return AjaxResult.success(iotRealDataList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * http get请求
|
|
|
+ *
|
|
|
+ * @param url 接口url
|
|
|
+ * @param token token
|
|
|
+ * @return 返回接口数据
|
|
|
+ */
|
|
|
+ protected static String executeGet(String url, String token) {
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ // 根据地址获取请求
|
|
|
+ HttpGet request = new HttpGet(url);//这⾥发送get请求
|
|
|
+ // 获取当前客户端对象
|
|
|
+ request.setHeader("Authorization", token);
|
|
|
+ HttpClient httpClient = new DefaultHttpClient();
|
|
|
+ // 通过请求对象获取响应对象
|
|
|
+ HttpResponse response = httpClient.execute(request);
|
|
|
+ // 判断⽹络连接状态码是否正常(0--200都数正常)
|
|
|
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SUCCESS) {
|
|
|
+ result = EntityUtils.toString(response.getEntity(), "utf-8");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block e.printStackTrace();
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|