Przeglądaj źródła

2023年9月25日09:44:55

纪新园 1 rok temu
rodzic
commit
790f3a9074

+ 21 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/OrderController.java

@@ -4,6 +4,7 @@ import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.web.controller.iot.domain.Device;
 import com.ruoyi.web.controller.iot.domain.Order;
 import com.ruoyi.web.controller.iot.service.IOrderService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,6 +37,15 @@ public class OrderController extends BaseController {
     }
 
     /**
+     * 客户端订单中心状态统计
+     */
+    @GetMapping("/accounting")
+    public AjaxResult accounting()
+    {
+        return orderService.accounting();
+    }
+
+    /**
      * 客户端订单中心详情
      */
     @GetMapping("/details")
@@ -48,9 +58,18 @@ public class OrderController extends BaseController {
      * 银行端设备管理列表
      */
     @GetMapping("/deviceList")
-    public TableDataInfo deviceList(Order order)
+    public TableDataInfo deviceList(Device device)
     {
-        return orderService.list(order);
+        return orderService.deviceList(device);
+    }
+
+    /**
+     * 银行端设备管理明细
+     */
+    @GetMapping("/deviceDetails")
+    public AjaxResult deviceDetails(Device device)
+    {
+        return orderService.deviceDetails(device);
     }
 
 }

+ 128 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/domain/Device.java

@@ -15,6 +15,10 @@ public class Device {
      */
     private Long equipmentName;
     /**
+     * 企业名称
+     */
+    private String enterpriseName;
+    /**
      * 设备编号
      */
     private Long equipmentCode;
@@ -22,10 +26,31 @@ public class Device {
      * 物模型id
      */
     private Long tslId;
+
+    /**
+     * 设备分类
+     */
+    private String tslName;
+
     /**
      * 设备图片
      */
     private Long equipmentImg;
+
+    /**
+     * 设备型号
+     */
+    private String model;
+
+    /**
+     * 设备品牌
+     */
+    private String brand;
+    /**
+     * 设备连接时间
+     */
+    private String connectionTime;
+
     /**
      * 序号
      */
@@ -39,6 +64,109 @@ public class Device {
      */
     private Long deptId;
 
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getConnectionTime() {
+        return connectionTime;
+    }
+
+    public void setConnectionTime(String connectionTime) {
+        this.connectionTime = connectionTime;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEquipmentName() {
+        return equipmentName;
+    }
+
+    public void setEquipmentName(Long equipmentName) {
+        this.equipmentName = equipmentName;
+    }
+
+    public String getEnterpriseName() {
+        return enterpriseName;
+    }
+
+    public void setEnterpriseName(String enterpriseName) {
+        this.enterpriseName = enterpriseName;
+    }
+
+    public Long getEquipmentCode() {
+        return equipmentCode;
+    }
+
+    public void setEquipmentCode(Long equipmentCode) {
+        this.equipmentCode = equipmentCode;
+    }
+
+    public Long getTslId() {
+        return tslId;
+    }
+
+    public void setTslId(Long tslId) {
+        this.tslId = tslId;
+    }
+
+    public String getTslName() {
+        return tslName;
+    }
+
+    public void setTslName(String tslName) {
+        this.tslName = tslName;
+    }
+
+    public Long getEquipmentImg() {
+        return equipmentImg;
+    }
+
+    public void setEquipmentImg(Long equipmentImg) {
+        this.equipmentImg = equipmentImg;
+    }
+
+    public Long getEquipmentSort() {
+        return equipmentSort;
+    }
+
+    public void setEquipmentSort(Long equipmentSort) {
+        this.equipmentSort = equipmentSort;
+    }
+
+    public Long getCreateUserId() {
+        return createUserId;
+    }
+
+    public void setCreateUserId(Long createUserId) {
+        this.createUserId = createUserId;
+    }
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
 }
 
 

+ 12 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/domain/Order.java

@@ -39,6 +39,10 @@ public class Order {
      */
     private Integer orderStatus;
     /**
+     * 列表显示字段
+     */
+    private String status;
+    /**
      * 订单负责人
      */
     private String orderManager;
@@ -99,6 +103,14 @@ public class Order {
      */
     private Integer workOrderNum;
 
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
     private List<ProductOrder> productOrderList;
 
     private TransportOrder transportOrder;

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/domain/ProductOrder.java

@@ -18,6 +18,10 @@ public class ProductOrder {
      * 工序id
      */
     private Long processId;
+    /**
+     * 工序名
+     */
+    private String processName;
      /**
      * 设备id
      */
@@ -59,6 +63,13 @@ public class ProductOrder {
      */
     private Integer stopNumber;
 
+    public String getProcessName() {
+        return processName;
+    }
+
+    public void setProcessName(String processName) {
+        this.processName = processName;
+    }
 
     public Long getId() {
         return id;

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/service/IOrderService.java

@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.iot.service;
 
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.web.controller.iot.domain.Device;
 import com.ruoyi.web.controller.iot.domain.Order;
 
 import java.util.List;
@@ -16,4 +17,10 @@ public interface IOrderService {
     TableDataInfo list(Order order);
 
     AjaxResult details(Order order);
+
+    TableDataInfo deviceList(Device device);
+
+    AjaxResult deviceDetails(Device device);
+
+    AjaxResult accounting();
 }

+ 120 - 11
ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/service/impl/OrderServiceImpl.java

@@ -5,6 +5,7 @@ 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.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;
@@ -16,7 +17,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author :jixinyuan
@@ -33,22 +36,31 @@ public class OrderServiceImpl implements IOrderService {
         Integer pageSize = pageDomain.getPageSize();
         String condition = "";
         if (!ObjectUtils.isEmpty(order.getOrderNum())) {
-            condition += "and find_in_set(order_num ,'" + order.getOrderNum() + "')";
+            condition += "and find_in_set(fo.order_num ,'" + order.getOrderNum() + "')";
         }
         if (!ObjectUtils.isEmpty(order.getOrderName())) {
-            condition += "and find_in_set(order_name , '" + order.getOrderName() + "')";
+            condition += "and find_in_set(fo.order_name , '" + order.getOrderName() + "')";
         }
-        if (!ObjectUtils.isEmpty(order.getOrderStatus())) {
-            condition += "and order_status = " + order.getOrderStatus();
+        if ("已逾期".equals(order.getStatus())) {
+            condition += "and fo.overdue = 1";
+        }
+        if ("生产中".equals(order.getStatus())) {
+            condition += "and fo.order_status = 1";
+        }
+        if ("已发货".equals(order.getStatus())) {
+            condition += "and tto.shipping_status = 1";
+        }
+        if ("已签收".equals(order.getStatus())) {
+            condition += "and tto.shipping_status = 2";
         }
         if (!ObjectUtils.isEmpty(order.getDeliveryCycle())) {
-            condition += "and delivery_cycle = " + order.getDeliveryCycle();
+            condition += "and fo.delivery_cycle = " + order.getDeliveryCycle();
         }
         if (!ObjectUtils.isEmpty(order.getStartTime())) {
-            condition += "and start_time >= '" + order.getStartTime() + "'";
+            condition += "and fo.start_time >= '" + order.getStartTime() + "'";
         }
         if (!ObjectUtils.isEmpty(order.getEndTime())) {
-            condition += "and end_time <= '" + order.getEndTime() + "'";
+            condition += "and fo.end_time <= '" + order.getEndTime() + "'";
         }
         Integer count = 0;
         try {
@@ -58,12 +70,25 @@ public class OrderServiceImpl implements IOrderService {
             dataSource.setUsername("db_cdyq6tkqn1ioja179i8b");
             dataSource.setPassword("By@#5c9i75sgtx3b620g6m6e");
             JdbcTemplate template = new JdbcTemplate(dataSource);
-            orderList = template.query("SELECT * FROM t_factory_order where 1=1 "
+            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));
-
-            count = template.queryForObject("SELECT count(*) FROM t_factory_order ;" , Integer.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 ("1".equals(item.getOverdue())) {
+                    item.setStatus("已逾期");
+                }
+            }
+            count = template.queryForObject("SELECT count(*) FROM t_factory_order;" , Integer.class);
         } catch (Exception e) {
             throw new RuntimeException(e.getMessage());
         }
@@ -87,7 +112,9 @@ public class OrderServiceImpl implements IOrderService {
             JdbcTemplate template = new JdbcTemplate(dataSource);
             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 * FROM t_product_order_detail where order_id = " + detail.getId() + ";" ,
+                List<ProductOrder> productOrderList = 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);
@@ -103,4 +130,86 @@ public class OrderServiceImpl implements IOrderService {
         }
         return AjaxResult.success(detail);
     }
+
+    @Override
+    public TableDataInfo deviceList(Device device) {
+        List<Device> orderList = new ArrayList<>();
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
+        Integer pageSize = pageDomain.getPageSize();
+        String condition = "";
+        if (!ObjectUtils.isEmpty(device.getEquipmentName())) {
+            condition += "and find_in_set(equipment_name ,'" + device.getEquipmentName() + "')";
+        }
+        if (!ObjectUtils.isEmpty(device.getEquipmentCode())) {
+            condition += "and find_in_set(equipment_code , '" + device.getEquipmentCode() + "')";
+        }
+        if (!ObjectUtils.isEmpty(device.getModel())) {
+            condition += "and find_in_set(equipment_code , '" + device.getModel() + "')";
+        }
+        if (!ObjectUtils.isEmpty(device.getEnterpriseName())) {
+            condition += "and order_status = " + device.getEnterpriseName();
+        }
+        if (!ObjectUtils.isEmpty(device.getConnectionTime())) {
+            condition += "and equipment_code >= '" + device.getConnectionTime() + "'";
+            condition += "and equipment_code <= '" + device.getConnectionTime() + "'";
+        }
+        Integer count = 0;
+        try {
+            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);
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        TableDataInfo tableDataInfo = new TableDataInfo();
+        tableDataInfo.setCode(HttpStatus.SUCCESS);
+        tableDataInfo.setMsg("查询成功");
+        tableDataInfo.setRows(orderList);
+        tableDataInfo.setTotal(count);
+        return tableDataInfo;
+    }
+
+    @Override
+    public AjaxResult deviceDetails(Device device) {
+        return null;
+    }
+
+    @Override
+    public AjaxResult accounting() {
+        Map<String, String> map = new HashMap<>();
+        try {
+            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 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 = 1 ;" , 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("count1" , count1 + "");
+            map.put("count2" , count2 + "");
+            map.put("count3" , count3 + "");
+            map.put("count4" , count4 + "");
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        return AjaxResult.success(map);
+    }
 }