Browse Source

2023年9月25日09:44:55

纪新园 1 year ago
parent
commit
c62ff4c828

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

@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.iot;
 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.Order;
 import com.ruoyi.web.controller.iot.service.IOrderService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.management.Query;
 import java.util.List;
 
 /**
@@ -28,10 +30,10 @@ public class OrderController extends BaseController {
      * 获取部门列表
      */
     @GetMapping("/list")
-    public AjaxResult list(Order order)
+    public TableDataInfo list(Order order, Query query)
     {
         List<Order> orderList = orderService.list(order);
-        return success(orderList);
+        return getDataTable(orderList);
     }
 
 }

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

@@ -1,8 +1,304 @@
 package com.ruoyi.web.controller.iot.domain;
 
+import java.util.Date;
+
 /**
  * @author :jixinyuan
  * @date : 2023/9/25
  */
+
 public class Order {
+
+    /**
+     * 主键
+     */
+    private Long id;
+    /**
+     * 订单编号
+     */
+    private String orderNum;
+    /**
+     * 订单名称
+     */
+    private String orderName;
+    /**
+     * 客户名称
+     */
+    private String customerName;
+    /**
+     * 订单数量
+     */
+    private Integer number;
+    /**
+     * 交付时间
+     */
+    private Date deliveryTime;
+    /**
+     * 0:创建 1:执行 2:完成 3:发货
+     */
+    private Integer orderStatus;
+    /**
+     * 订单负责人
+     */
+    private String orderManager;
+    /**
+     * 单位
+     */
+    private String unit;
+    /**
+     * 图片介绍
+     */
+    private String imageIntroduction;
+    /**
+     * 附件
+     */
+    private String attachments;
+    /**
+     * 完成数量
+     */
+    private Integer finishNum;
+    /**
+     * 订单开始时间
+     */
+    private Date startTime;
+    /**
+     * 订单结束时间
+     */
+    private Date endTime;
+    /**
+     * 订单创建时间
+     */
+    private Date createTime;
+    /**
+     * 交付周期
+     */
+    private Integer deliveryCycle;
+    /**
+     * 订单来源
+     */
+    private String orderSource;
+    /**
+     * 是否逾期:0 否 1 是
+     */
+    private String overdue;
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+    /**
+     * 付款方式
+     */
+    private String payMethod;
+    /**
+     * 备注
+     */
+    private String notes;
+    /**
+     * 需要拆分的工单数量
+     */
+    private Integer workOrderNum;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getOrderNum() {
+        return orderNum;
+    }
+
+    public void setOrderNum(String orderNum) {
+        this.orderNum = orderNum;
+    }
+
+    public String getOrderName() {
+        return orderName;
+    }
+
+    public void setOrderName(String orderName) {
+        this.orderName = orderName;
+    }
+
+    public String getCustomerName() {
+        return customerName;
+    }
+
+    public void setCustomerName(String customerName) {
+        this.customerName = customerName;
+    }
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public Date getDeliveryTime() {
+        return deliveryTime;
+    }
+
+    public void setDeliveryTime(Date deliveryTime) {
+        this.deliveryTime = deliveryTime;
+    }
+
+    public Integer getOrderStatus() {
+        return orderStatus;
+    }
+
+    public void setOrderStatus(Integer orderStatus) {
+        this.orderStatus = orderStatus;
+    }
+
+    public String getOrderManager() {
+        return orderManager;
+    }
+
+    public void setOrderManager(String orderManager) {
+        this.orderManager = orderManager;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+
+    public String getImageIntroduction() {
+        return imageIntroduction;
+    }
+
+    public void setImageIntroduction(String imageIntroduction) {
+        this.imageIntroduction = imageIntroduction;
+    }
+
+    public String getAttachments() {
+        return attachments;
+    }
+
+    public void setAttachments(String attachments) {
+        this.attachments = attachments;
+    }
+
+    public Integer getFinishNum() {
+        return finishNum;
+    }
+
+    public void setFinishNum(Integer finishNum) {
+        this.finishNum = finishNum;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Integer getDeliveryCycle() {
+        return deliveryCycle;
+    }
+
+    public void setDeliveryCycle(Integer deliveryCycle) {
+        this.deliveryCycle = deliveryCycle;
+    }
+
+    public String getOrderSource() {
+        return orderSource;
+    }
+
+    public void setOrderSource(String orderSource) {
+        this.orderSource = orderSource;
+    }
+
+    public String getOverdue() {
+        return overdue;
+    }
+
+    public void setOverdue(String overdue) {
+        this.overdue = overdue;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getPayMethod() {
+        return payMethod;
+    }
+
+    public void setPayMethod(String payMethod) {
+        this.payMethod = payMethod;
+    }
+
+    public String getNotes() {
+        return notes;
+    }
+
+    public void setNotes(String notes) {
+        this.notes = notes;
+    }
+
+    public Integer getWorkOrderNum() {
+        return workOrderNum;
+    }
+
+    public void setWorkOrderNum(Integer workOrderNum) {
+        this.workOrderNum = workOrderNum;
+    }
+
+    @Override
+    public String toString() {
+        return "Order{" +
+                "id=" + id +
+                ", 订单编号='" + orderNum + '\'' +
+                ", 订单名称='" + orderName + '\'' +
+                ", 客户名称='" + customerName + '\'' +
+                ", 订单数量='" + number + '\'' +
+                ", 交付时间='" + deliveryTime + '\'' +
+                ", 状态='" + orderStatus + '\'' +
+                ", 订单负责人='" + orderManager + '\'' +
+                ", 单位='" + unit + '\'' +
+                ", 图片介绍='" + imageIntroduction + '\'' +
+                ", 附件='" + attachments + '\'' +
+                ", 完成数量='" + finishNum + '\'' +
+                ", 订单开始时间='" + startTime + '\'' +
+                ", 订单结束时间='" + endTime + '\'' +
+                ", 订单创建时间='" + createTime + '\'' +
+                ", 交付周期='" + deliveryCycle + '\'' +
+                ", 订单来源='" + orderSource + '\'' +
+                ", 是否逾期='" + overdue + '\'' +
+                ", 更新时间='" + updateTime + '\'' +
+                ", 付款方式='" + payMethod + '\'' +
+                ", 备注='" + notes + '\'' +
+                ", 需要拆分的工单数量='" + workOrderNum + '\'' +
+                '}';
+    }
 }

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

@@ -1,13 +1,16 @@
 package com.ruoyi.web.controller.iot.service.impl;
 
-import com.ruoyi.common.constant.HttpStatus;
+import com.ruoyi.common.core.page.PageDomain;
+import com.ruoyi.common.core.page.TableSupport;
 import com.ruoyi.web.controller.iot.domain.Order;
 import com.ruoyi.web.controller.iot.service.IOrderService;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.datasource.DriverManagerDataSource;
-import org.springframework.jdbc.support.rowset.SqlRowSet;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -19,23 +22,49 @@ public class OrderServiceImpl implements IOrderService {
 
     @Override
     public List<Order> list(Order order) {
+        List<Order> orderList = new ArrayList<>();
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum()-1;
+        Integer pageSize = pageDomain.getPageSize();
+        String condition = "";
+        if (!ObjectUtils.isEmpty(order.getOrderNum())) {
+            condition += "and find_in_set(order_num ,'" + order.getOrderNum() + "')";
+        }
+        if (!ObjectUtils.isEmpty(order.getOrderName())) {
+            condition += "and find_in_set(order_name , '" + order.getOrderName() + "')";
+        }
+        if (!ObjectUtils.isEmpty(order.getOrderStatus())) {
+            condition += "and order_status = " + order.getOrderStatus();
+        }
+        if (!ObjectUtils.isEmpty(order.getDeliveryCycle())) {
+            condition += "and delivery_cycle = " + order.getDeliveryCycle();
+        }
+        if (!ObjectUtils.isEmpty(order.getStartTime())) {
+            condition += "and start_time >= " + order.getStartTime();
+        }
+        if (!ObjectUtils.isEmpty(order.getEndTime())) {
+            condition += "and end_time <= " + order.getEndTime();
+        }
         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");
-
+            System.out.println("SELECT * FROM t_factory_order where 1=1 "
+                    + (ObjectUtils.isEmpty(condition) ? "" : condition)
+                    + " limit " + pageNum + "," + pageSize + ";");
             JdbcTemplate template = new JdbcTemplate(dataSource);
-            SqlRowSet sqlRowSet = template.queryForRowSet("SELECT * FROM 't_factory_order';");
-
-            System.err.println("返回数据:"+sqlRowSet);
-
+            orderList = template.query("SELECT * FROM t_factory_order where 1=1 "
+                            + (ObjectUtils.isEmpty(condition) ? "" : condition)
+                            + " limit " + pageNum + "," + pageSize + ";" ,
+                    new BeanPropertyRowMapper<Order>(Order.class));
+            for (Order item : orderList) {
+                System.out.println("返回数据:" + item.toString());
+            }
         } catch (Exception e) {
-            System.err.println(e.getMessage());
-            return null;
-//            return new ResponseEntity<ResponseStatusDto>(ResponseStatusDto.createErrorDto(e.getMessage(), e), HttpStatus.ACCEPTED);
+            throw new RuntimeException(e.getMessage());
         }
-        return null;
+        return orderList;
     }
 }