Bladeren bron

生产排程

yzc 1 jaar geleden
bovenliggende
commit
d3164cfaa3

+ 4 - 3
hx-mes/src/main/java/com/fjhx/mes/controller/production/ProductionSchedulingController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -31,9 +32,9 @@ public class ProductionSchedulingController {
     /**
      * 生产排程列表
      */
-    @PostMapping("/list")
-    public List<ProductionSchedulingVo> list(@RequestBody ProductionSchedulingSelectDto dto) {
-        return productionSchedulingService.getList(dto);
+    @PostMapping("/listMap")
+    public Map<String, List<ProductionSchedulingVo>> listMap(@RequestBody ProductionSchedulingSelectDto dto) {
+        return productionSchedulingService.listMap(dto);
     }
 
     /**

+ 14 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/production/vo/ProductionSchedulingVo.java

@@ -14,4 +14,18 @@ import lombok.Setter;
 @Setter
 public class ProductionSchedulingVo extends ProductionScheduling {
 
+    /**
+     * 工序名称
+     */
+    private String processesName;
+    /**
+     * 负载量
+     */
+    private Integer capacity;
+
+    /**
+     * 排程时间字符串
+     */
+    private String schedulingDateStr;
+
 }

+ 2 - 2
hx-mes/src/main/java/com/fjhx/mes/mapper/production/ProductionSchedulingMapper.java

@@ -19,8 +19,8 @@ import java.util.List;
 public interface ProductionSchedulingMapper extends BaseMapper<ProductionScheduling> {
 
     /**
-     * 生产排程列表
+     * 排程合并数量
      */
-    List<ProductionSchedulingVo> getList(@Param("ew") IWrapper<ProductionScheduling> wrapper);
+    List<ProductionSchedulingVo> listSumQuantity(@Param("ew") IWrapper<ProductionScheduling> wrapper);
 
 }

+ 2 - 4
hx-mes/src/main/java/com/fjhx/mes/service/production/ProductionSchedulingService.java

@@ -7,6 +7,7 @@ import com.fjhx.mes.entity.production.vo.ProductionSchedulingVo;
 import com.ruoyi.common.core.service.BaseService;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -18,10 +19,7 @@ import java.util.List;
  */
 public interface ProductionSchedulingService extends BaseService<ProductionScheduling> {
 
-    /**
-     * 生产排程列表
-     */
-    List<ProductionSchedulingVo> getList(ProductionSchedulingSelectDto dto);
+    Map<String, List<ProductionSchedulingVo>> listMap(ProductionSchedulingSelectDto dto);
 
     /**
      * 生产排程新增

+ 12 - 4
hx-mes/src/main/java/com/fjhx/mes/service/production/impl/ProductionSchedulingServiceImpl.java

@@ -11,6 +11,8 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -24,11 +26,17 @@ import java.util.List;
 public class ProductionSchedulingServiceImpl extends ServiceImpl<ProductionSchedulingMapper, ProductionScheduling> implements ProductionSchedulingService {
 
     @Override
-    public List<ProductionSchedulingVo> getList(ProductionSchedulingSelectDto dto) {
+    public Map<String, List<ProductionSchedulingVo>> listMap(ProductionSchedulingSelectDto dto) {
         IWrapper<ProductionScheduling> wrapper = getWrapper();
-        wrapper.orderByDesc("ps", ProductionScheduling::getId);
-        List<ProductionSchedulingVo> list = this.baseMapper.getList(wrapper);
-        return list;
+        //数据分组
+        wrapper.groupBy("ps.scheduling_date", "ps.processes_id");
+        //时间范围过滤
+        wrapper.ge("ps", ProductionScheduling::getSchedulingDate, dto.getBeginTime());
+        wrapper.le("ps", ProductionScheduling::getSchedulingDate, dto.getEndTime());
+        //排序
+        wrapper.orderByAsc("ps", ProductionScheduling::getSchedulingDate);
+        List<ProductionSchedulingVo> list = this.baseMapper.listSumQuantity(wrapper);
+        return list.stream().collect(Collectors.groupingBy(ProductionSchedulingVo::getSchedulingDateStr));
     }
 
     @Override

+ 9 - 10
hx-mes/src/main/resources/mapper/production/ProductionSchedulingMapper.xml

@@ -1,17 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.mes.mapper.production.ProductionSchedulingMapper">
-    <select id="getList" resultType="com.fjhx.mes.entity.production.vo.ProductionSchedulingVo">
-        select ps.id,
-               ps.task_id,
+
+    <select id="listSumQuantity" resultType="com.fjhx.mes.entity.production.vo.ProductionSchedulingVo">
+        SELECT ps.scheduling_date,
+               DATE_FORMAT(ps.scheduling_date, '%Y-%m-%d') AS schedulingDateStr,
+               sum(ps.quantity)                            AS quantity,
                ps.processes_id,
-               ps.scheduling_date,
-               ps.quantity,
-               ps.create_user,
-               ps.create_time,
-               ps.update_user,
-               ps.update_time
-        from production_scheduling ps
+               pp.`name`                                   AS processesName,
+               pp.capacity
+        FROM production_scheduling ps
+                 JOIN production_processes pp ON ps.processes_id = pp.id
             ${ew.customSqlSegment}
     </select>