Kaynağa Gözat

APS平台初始化

fangpy 1 yıl önce
ebeveyn
işleme
82b6c6a51d
31 değiştirilmiş dosya ile 477 ekleme ve 627 silme
  1. 51 14
      pom.xml
  2. 33 0
      rw-aps-server/.gitignore
  3. 98 0
      rw-aps-server/pom.xml
  4. 19 0
      rw-aps-server/src/main/java/com/rongwei/rwapsserver/RwApsServerApplication.java
  5. 10 10
      src/main/java/com/rongwei/aps/ApsBalancingApplication.java
  6. 33 0
      rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/controller/ApsSchedulingController.java
  7. 1 1
      src/main/java/com/rongwei/aps/domain/ApsAbstractPersistable.java
  8. 1 1
      src/main/java/com/rongwei/aps/domain/ApsSolution.java
  9. 1 1
      src/main/java/com/rongwei/aps/domain/Equipment.java
  10. 2 1
      src/main/java/com/rongwei/aps/domain/ProduceOrder.java
  11. 1 1
      src/main/java/com/rongwei/aps/domain/Product.java
  12. 1 1
      src/main/java/com/rongwei/aps/domain/ProductionProcesses.java
  13. 3 5
      src/main/java/com/rongwei/aps/score/ApsConstraintProvider.java
  14. 10 0
      rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/ProductionScheduleService.java
  15. 82 0
      rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/impl/ProductionScheduleServiceImpl.java
  16. 7 0
      rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/vo/ProductionScheduleRetVo.java
  17. 21 0
      rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/vo/ProductionScheduleVo.java
  18. 19 0
      rw-aps-server/src/main/resources/bootstrap-dev.yml
  19. 12 0
      rw-aps-server/src/main/resources/bootstrap-pro.yml
  20. 59 0
      rw-aps-server/src/main/resources/bootstrap.yml
  21. 13 0
      rw-aps-server/src/test/java/com/rongwei/rwapsserver/RwApsServerApplicationTests.java
  22. 0 52
      src/main/java/com/rongwei/cloudbalancing/CloudBalancingApplication.java
  23. 0 30
      src/main/java/com/rongwei/cloudbalancing/domain/AbstractPersistable.java
  24. 0 76
      src/main/java/com/rongwei/cloudbalancing/domain/CloudBalance.java
  25. 0 31
      src/main/java/com/rongwei/cloudbalancing/domain/CloudComputer.java
  26. 0 40
      src/main/java/com/rongwei/cloudbalancing/domain/CloudProcess.java
  27. 0 18
      src/main/java/com/rongwei/cloudbalancing/domain/solver/CloudComputerStrengthComparator.java
  28. 0 14
      src/main/java/com/rongwei/cloudbalancing/domain/solver/CloudProcessDifficultyComparator.java
  29. 0 235
      src/main/java/com/rongwei/cloudbalancing/persistence/CloudBalancingGenerator.java
  30. 0 63
      src/main/java/com/rongwei/cloudbalancing/score/CloudBalancingConstraintProvider.java
  31. 0 33
      src/main/resources/logback.xml

+ 51 - 14
pom.xml

@@ -4,16 +4,25 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
-    <groupId>org.example</groupId>
+    <groupId>com.rongwei</groupId>
     <artifactId>rw-aps</artifactId>
     <version>1.0-SNAPSHOT</version>
 
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>rw-aps-server</module>
+    </modules>
+
     <properties>
         <maven.compiler.source>11</maven.compiler.source>
         <maven.compiler.target>11</maven.compiler.target>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-
         <version.org.optaplanner>9.44.0.Final</version.org.optaplanner>
+        <spring.cloud.version>2021.0.6</spring.cloud.version>
+        <nacos.client.version>1.4.2</nacos.client.version>
+        <mysql.version>8.0.21</mysql.version>
+        <druid.starter.version>1.2.6</druid.starter.version>
     </properties>
 
     <parent>
@@ -23,15 +32,6 @@
     </parent>
 
     <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.optaplanner</groupId>
-            <artifactId>optaplanner-spring-boot-starter</artifactId>
-            <version>${version.org.optaplanner}</version>
-        </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
@@ -43,13 +43,50 @@
         </dependency>
     </dependencies>
 
-    <build>
+    <!--依赖管理,用于管理spring-cloud的依赖,其中Camden.SR3是版本号-->
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>2021.0.5</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>com.alibaba</groupId>
+                <artifactId>fastjson</artifactId>
+                <version>1.2.33</version>
+            </dependency>
+            <dependency>
+                <groupId>com.alibaba.cloud</groupId>
+                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
+                <version>2021.0.5.0</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <distributionManagement>
+        <snapshotRepository>
+            <id>ossrh</id>
+            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+        </snapshotRepository>
+        <repository>
+            <id>ossrh</id>
+            <name>Maven Central Staging Repository</name>
+            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+        </repository>
+    </distributionManagement>
+
+    <!--<build>
         <plugins>
-            <!-- spring boot提供的核心maven插件 -->
+            &lt;!&ndash; spring boot提供的核心maven插件 &ndash;&gt;
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
         </plugins>
-    </build>
+    </build>-->
 </project>

+ 33 - 0
rw-aps-server/.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 98 - 0
rw-aps-server/pom.xml

@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.rongwei</groupId>
+        <artifactId>rw-aps</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <groupId>com.rongwei</groupId>
+    <artifactId>rw-aps-server</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>rw-aps-server</name>
+    <description>rw-aps-server</description>
+    <properties>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <version.org.optaplanner>9.44.0.Final</version.org.optaplanner>
+        <spring.cloud.version>2021.0.6</spring.cloud.version>
+        <nacos.client.version>1.4.2</nacos.client.version>
+        <mysql.version>8.0.21</mysql.version>
+        <druid.starter.version>1.2.6</druid.starter.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.optaplanner</groupId>
+            <artifactId>optaplanner-spring-boot-starter</artifactId>
+            <version>${version.org.optaplanner}</version>
+        </dependency>
+        <!-- Spring Cloud Begin -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.nacos</groupId>
+            <artifactId>nacos-client</artifactId>
+            <version>${nacos.client.version}</version>
+        </dependency>
+        <!-- Spring Cloud End -->
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>3.1.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>${druid.starter.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 19 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/RwApsServerApplication.java

@@ -0,0 +1,19 @@
+package com.rongwei.rwapsserver;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients
+@MapperScan("com.rongwei.*.*.dao")
+public class RwApsServerApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(RwApsServerApplication.class, args);
+    }
+
+}

+ 10 - 10
src/main/java/com/rongwei/aps/ApsBalancingApplication.java

@@ -1,11 +1,11 @@
-package com.rongwei.aps;
+package com.rongwei.rwapsserver.aps;
 
 import cn.hutool.core.date.DateUtil;
-import com.rongwei.aps.domain.ApsSolution;
-import com.rongwei.aps.domain.Equipment;
-import com.rongwei.aps.domain.ProduceOrder;
-import com.rongwei.aps.domain.ProductionProcesses;
-import com.rongwei.aps.score.ApsConstraintProvider;
+import com.rongwei.rwapsserver.aps.domain.ApsSolution;
+import com.rongwei.rwapsserver.aps.domain.Equipment;
+import com.rongwei.rwapsserver.aps.domain.ProduceOrder;
+import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
+import com.rongwei.rwapsserver.aps.score.ApsConstraintProvider;
 import lombok.extern.slf4j.Slf4j;
 import org.optaplanner.core.api.solver.Solver;
 import org.optaplanner.core.api.solver.SolverFactory;
@@ -36,7 +36,7 @@ public class ApsBalancingApplication {
     }
 
     private static void testAps(){
-//        log.info("app start...");
+        log.info("app start...");
         SolverFactory<ApsSolution> solverFactory = SolverFactory.create(new SolverConfig()
                 .withSolutionClass(ApsSolution.class)
                 .withEntityClasses(ProductionProcesses.class)
@@ -49,7 +49,7 @@ public class ApsBalancingApplication {
         // Display the computer list
 //        System.out.println("\nComputers:\n" + unsolvedCloudBalance.toStringComputerList());
 
-//        log.info("start to solve...");
+        log.info("start to solve...");
         ApsSolution solvedBalance = solver.solve(getTestApsSolution());
         System.out.println(solvedBalance);
         // Display the result
@@ -80,8 +80,8 @@ public class ApsBalancingApplication {
         // 工步初始化
         List<ProductionProcesses> processes = new ArrayList<>();
         // 订单初始化
-        ProduceOrder produceOrder1 = new ProduceOrder("order1","订单1", DateUtil.parseDateTime("2024-02-28 21:52:12"));
-        ProduceOrder produceOrder2 = new ProduceOrder("order2","订单2", DateUtil.parseDateTime("2024-02-28 19:20:12"));
+        ProduceOrder produceOrder1 = new ProduceOrder("order1","订单1", DateUtil.parseDateTime("2024-02-29 21:52:12"));
+        ProduceOrder produceOrder2 = new ProduceOrder("order2","订单2", DateUtil.parseDateTime("2024-02-29 19:20:12"));
         ProductionProcesses p1 = new ProductionProcesses(1,"均热炉",Arrays.asList(new ProduceOrder[]{produceOrder1}),10);
         ProductionProcesses p2 = new ProductionProcesses(2,"卧式分切机",Arrays.asList(new ProduceOrder[]{produceOrder1}),12);
         ProductionProcesses p6 = new ProductionProcesses(6,"氮气保护退火炉",Arrays.asList(new ProduceOrder[]{produceOrder1,produceOrder2}),72);

+ 33 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/controller/ApsSchedulingController.java

@@ -0,0 +1,33 @@
+package com.rongwei.rwapsserver.aps.controller;
+
+import com.rongwei.rwapsserver.aps.service.ProductionScheduleService;
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleRetVo;
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleVo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * APS排程接口
+ */
+@RestController
+@RequestMapping("apsSchedule")
+@Slf4j
+public class ApsSchedulingController {
+
+    @Autowired
+    private ProductionScheduleService productionScheduleService;
+
+    /**
+     * 流程任务运行API
+     * @param productionScheduleVo
+     * @return
+     */
+    @RequestMapping("/productionSchedule")
+    public ProductionScheduleRetVo productionSchedule(@RequestBody ProductionScheduleVo productionScheduleVo) throws Exception{
+        return productionScheduleService.productionSchedule(productionScheduleVo);
+    }
+
+}

+ 1 - 1
src/main/java/com/rongwei/aps/domain/ApsAbstractPersistable.java

@@ -1,4 +1,4 @@
-package com.rongwei.aps.domain;
+package com.rongwei.rwapsserver.aps.domain;
 
 import org.optaplanner.core.api.domain.lookup.PlanningId;
 

+ 1 - 1
src/main/java/com/rongwei/aps/domain/ApsSolution.java

@@ -1,4 +1,4 @@
-package com.rongwei.aps.domain;
+package com.rongwei.rwapsserver.aps.domain;
 
 import lombok.*;
 import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;

+ 1 - 1
src/main/java/com/rongwei/aps/domain/Equipment.java

@@ -1,4 +1,4 @@
-package com.rongwei.aps.domain;
+package com.rongwei.rwapsserver.aps.domain;
 
 import lombok.Data;
 import lombok.EqualsAndHashCode;

+ 2 - 1
src/main/java/com/rongwei/aps/domain/ProduceOrder.java

@@ -1,6 +1,7 @@
-package com.rongwei.aps.domain;
+package com.rongwei.rwapsserver.aps.domain;
 
 import lombok.Data;
+
 import java.util.Date;
 import java.util.List;
 

+ 1 - 1
src/main/java/com/rongwei/aps/domain/Product.java

@@ -1,4 +1,4 @@
-package com.rongwei.aps.domain;
+package com.rongwei.rwapsserver.aps.domain;
 
 import java.math.BigDecimal;
 

+ 1 - 1
src/main/java/com/rongwei/aps/domain/ProductionProcesses.java

@@ -1,4 +1,4 @@
-package com.rongwei.aps.domain;
+package com.rongwei.rwapsserver.aps.domain;
 
 import org.optaplanner.core.api.domain.entity.PlanningEntity;
 import org.optaplanner.core.api.domain.variable.PlanningVariable;

+ 3 - 5
src/main/java/com/rongwei/aps/score/ApsConstraintProvider.java

@@ -1,10 +1,9 @@
-package com.rongwei.aps.score;
+package com.rongwei.rwapsserver.aps.score;
 
-import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
-import com.rongwei.aps.domain.ProduceOrder;
-import com.rongwei.aps.domain.ProductionProcesses;
+import com.rongwei.rwapsserver.aps.domain.ProduceOrder;
+import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
 import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
 import org.optaplanner.core.api.score.stream.Constraint;
 import org.optaplanner.core.api.score.stream.ConstraintFactory;
@@ -16,7 +15,6 @@ import java.time.ZoneId;
 import java.util.Date;
 
 import static org.optaplanner.core.api.score.stream.ConstraintCollectors.count;
-import static org.optaplanner.core.api.score.stream.ConstraintCollectors.sum;
 
 public class ApsConstraintProvider implements ConstraintProvider {
 

+ 10 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/ProductionScheduleService.java

@@ -0,0 +1,10 @@
+package com.rongwei.rwapsserver.aps.service;
+
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleRetVo;
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleVo;
+
+public interface ProductionScheduleService {
+
+    ProductionScheduleRetVo productionSchedule(ProductionScheduleVo productionScheduleVo);
+
+}

+ 82 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/impl/ProductionScheduleServiceImpl.java

@@ -0,0 +1,82 @@
+package com.rongwei.rwapsserver.aps.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import com.rongwei.rwapsserver.aps.domain.ApsSolution;
+import com.rongwei.rwapsserver.aps.domain.Equipment;
+import com.rongwei.rwapsserver.aps.domain.ProduceOrder;
+import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
+import com.rongwei.rwapsserver.aps.score.ApsConstraintProvider;
+import com.rongwei.rwapsserver.aps.service.ProductionScheduleService;
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleRetVo;
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleVo;
+import org.optaplanner.core.api.solver.Solver;
+import org.optaplanner.core.api.solver.SolverFactory;
+import org.optaplanner.core.config.solver.SolverConfig;
+import org.springframework.stereotype.Service;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@Service
+public class ProductionScheduleServiceImpl implements ProductionScheduleService {
+
+    @Override
+    public ProductionScheduleRetVo productionSchedule(ProductionScheduleVo productionScheduleVo) {
+        ProductionScheduleRetVo productionScheduleRetVo = new ProductionScheduleRetVo();
+        SolverFactory<ApsSolution> solverFactory = SolverFactory.create(new SolverConfig()
+                .withSolutionClass(ApsSolution.class)
+                .withEntityClasses(ProductionProcesses.class)
+                .withConstraintProviderClass(ApsConstraintProvider.class)
+                .withTerminationSpentLimit(Duration.ofSeconds(5)));
+        Solver<ApsSolution> solver = solverFactory.buildSolver();
+        ApsSolution solvedBalance = solver.solve(getTestApsSolution());
+        System.out.println(solvedBalance);
+        return productionScheduleRetVo;
+    }
+
+    private static ApsSolution getTestApsSolution(){
+        ApsSolution unsolvedCloudBalance = new ApsSolution();
+        // 设备列表初始化
+        List<Equipment> equipmentList = new ArrayList<>();
+        Equipment eq1 = new Equipment(1,"均热炉");
+        Equipment eq2 = new Equipment(2,"均热炉");
+        Equipment eq3 = new Equipment(3,"卧式分切机");
+        Equipment eq4 = new Equipment(4,"卧式分切机");
+        Equipment eq5 = new Equipment(5,"卧式分切机");
+        Equipment eq6 = new Equipment(6,"厚纵剪");
+        Equipment eq7 = new Equipment(7,"厚纵剪");
+        Equipment eq8 = new Equipment(8,"氮气保护退火炉");
+        equipmentList.add(eq1);
+        equipmentList.add(eq2);
+        equipmentList.add(eq3);
+        equipmentList.add(eq4);
+        equipmentList.add(eq5);
+        equipmentList.add(eq6);
+        equipmentList.add(eq7);
+        equipmentList.add(eq8);
+        unsolvedCloudBalance.setEquipmentList(equipmentList);
+        // 工步初始化
+        List<ProductionProcesses> processes = new ArrayList<>();
+        // 订单初始化
+        ProduceOrder produceOrder1 = new ProduceOrder("order1","订单1", DateUtil.parseDateTime("2024-02-29 21:52:12"));
+        ProduceOrder produceOrder2 = new ProduceOrder("order2","订单2", DateUtil.parseDateTime("2024-02-29 19:20:12"));
+        ProductionProcesses p1 = new ProductionProcesses(1,"均热炉", Arrays.asList(new ProduceOrder[]{produceOrder1}),10);
+        ProductionProcesses p2 = new ProductionProcesses(2,"卧式分切机",Arrays.asList(new ProduceOrder[]{produceOrder1}),12);
+        ProductionProcesses p6 = new ProductionProcesses(6,"氮气保护退火炉",Arrays.asList(new ProduceOrder[]{produceOrder1,produceOrder2}),72);
+        p6.setMergeProcessMark("tuihuolu");
+        p1.setNextProcesses(Arrays.asList(new ProductionProcesses[]{p2}));p2.setPreviousProcesses(Arrays.asList(new ProductionProcesses[]{p1}));
+        p2.setNextProcesses(Arrays.asList(new ProductionProcesses[]{p6}));
+        processes.add(p1);processes.add(p2);
+        ProductionProcesses p3 = new ProductionProcesses(3,"均热炉",Arrays.asList(new ProduceOrder[]{produceOrder2}),10);
+        ProductionProcesses p4 = new ProductionProcesses(4,"卧式分切机",Arrays.asList(new ProduceOrder[]{produceOrder2}),12);
+        ProductionProcesses p5 = new ProductionProcesses(5,"厚纵剪",Arrays.asList(new ProduceOrder[]{produceOrder2}),23);
+        p3.setNextProcesses(Arrays.asList(new ProductionProcesses[]{p4}));p4.setPreviousProcesses(Arrays.asList(new ProductionProcesses[]{p3}));
+        p4.setNextProcesses(Arrays.asList(new ProductionProcesses[]{p5}));p5.setPreviousProcesses(Arrays.asList(new ProductionProcesses[]{p4}));
+        p5.setNextProcesses(Arrays.asList(new ProductionProcesses[]{p6}));p6.setPreviousProcesses(Arrays.asList(new ProductionProcesses[]{p2,p5}));
+        processes.add(p3);processes.add(p4);processes.add(p5);processes.add(p6);
+        unsolvedCloudBalance.setProcessesList(processes);
+        return unsolvedCloudBalance;
+    }
+}

+ 7 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/vo/ProductionScheduleRetVo.java

@@ -0,0 +1,7 @@
+package com.rongwei.rwapsserver.aps.vo;
+
+import lombok.Data;
+
+@Data
+public class ProductionScheduleRetVo {
+}

+ 21 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/vo/ProductionScheduleVo.java

@@ -0,0 +1,21 @@
+package com.rongwei.rwapsserver.aps.vo;
+
+import com.rongwei.rwapsserver.aps.domain.Equipment;
+import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ProductionScheduleVo {
+
+    /**
+     * 生产工序集合
+     */
+    private List<ProductionProcesses> processes;
+
+    /**
+     * 生产设备集合
+     */
+    private List<Equipment> equipmentList;
+}

+ 19 - 0
rw-aps-server/src/main/resources/bootstrap-dev.yml

@@ -0,0 +1,19 @@
+spring:
+  cloud:
+    nacos:
+      config:
+        file-extension: yaml
+        server-addr: 127.0.0.1:8848
+        namespace: cd047569-9470-4dfb-8663-b113d01cd30f
+        ext-config[0]:
+          data-id: common-config.yaml
+      discovery:
+        server-addr: 127.0.0.1:8848
+        namespace: cd047569-9470-4dfb-8663-b113d01cd30f
+        metadata:
+          management:
+            context-path: ${server.servlet.context-path}/actuator
+#    sentinel:
+#      transport:
+#        dashboard: localhost:8080
+#        port: 8719

+ 12 - 0
rw-aps-server/src/main/resources/bootstrap-pro.yml

@@ -0,0 +1,12 @@
+spring:
+  cloud:
+    nacos:
+      config:
+        file-extension: yaml
+        server-addr: nacos:8848
+        namespace: 75f91d9a-0dd2-4dd9-98f6-61a221d396f1
+        ext-config[0]:
+          data-id: common-config.yaml
+      discovery:
+        server-addr: nacos:8848
+        namespace: 75f91d9a-0dd2-4dd9-98f6-61a221d396f1

+ 59 - 0
rw-aps-server/src/main/resources/bootstrap.yml

@@ -0,0 +1,59 @@
+spring:
+  profiles:
+    active: dev
+  application:
+    name: rw-aps
+  servlet:
+    multipart:
+      max-file-size: 100MB
+      max-request-size: 1000MB
+server:
+  port: 9358
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: always
+feign:
+  client:
+    config:
+      default:
+        connectTimeout: 10000
+        readTimeout: 10000
+  sentinel:
+    enabled: true
+jwt:
+  token-header: Authorization
+  expire: 14400
+  rsa-secret: xx1WET12^%3^(WE45
+client:
+  id: ace-auth
+  secret: 123456
+  token-header: x-client-token
+  expire: 14400
+  rsa-secret: x2318^^(*WRYQWR(QW&T
+mybatis-plus:
+  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
+    map-underscore-to-camel-case: false
+  #basepackage: com.rongwei.rwadmin.system.dao
+  xmlLocation: classpath:mybatis/**/*Dao.xml
+  mapperLocations: "classpath:mybatis/**/*Dao.xml"
+  typeAliasesPackage: com.rongwei.rwadmincommon.**.domain
+  global-config:
+    db-config:
+      logic-delete-value: 1
+      logic-not-delete-value: 0
+#      column-like: true
+#  type-aliases-package: com.rongwei.rwadmin.**.domain
+#mapper:
+#  mappers: com.rongwei.rwadmin.common.mapper.BaseDao
+#  identity: MYSQL
+security:
+  csrf:
+    enable: false
+    excludes:

+ 13 - 0
rw-aps-server/src/test/java/com/rongwei/rwapsserver/RwApsServerApplicationTests.java

@@ -0,0 +1,13 @@
+package com.rongwei.rwapsserver;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class RwApsServerApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}

+ 0 - 52
src/main/java/com/rongwei/cloudbalancing/CloudBalancingApplication.java

@@ -1,52 +0,0 @@
-package com.rongwei.cloudbalancing;
-
-import com.rongwei.cloudbalancing.domain.CloudBalance;
-import com.rongwei.cloudbalancing.domain.CloudComputer;
-import com.rongwei.cloudbalancing.domain.CloudProcess;
-import com.rongwei.cloudbalancing.persistence.CloudBalancingGenerator;
-import com.rongwei.cloudbalancing.score.CloudBalancingConstraintProvider;
-import lombok.extern.slf4j.Slf4j;
-import org.optaplanner.core.api.solver.Solver;
-import org.optaplanner.core.api.solver.SolverFactory;
-import org.optaplanner.core.config.solver.SolverConfig;
-
-import java.time.Duration;
-
-@Slf4j
-public class CloudBalancingApplication {
-    public static void main(String[] args) {
-        log.info("app start...");
-        SolverFactory<CloudBalance> solverFactory = SolverFactory.create(new SolverConfig()
-                .withSolutionClass(CloudBalance.class)
-                .withEntityClasses(CloudProcess.class)
-                .withConstraintProviderClass(CloudBalancingConstraintProvider.class)
-                .withTerminationSpentLimit(Duration.ofSeconds(5)));
-        Solver<CloudBalance> solver = solverFactory.buildSolver();
-
-        CloudBalance unsolvedCloudBalance = new CloudBalancingGenerator().createCloudBalance(3, 20);
-
-        System.out.println("\nProcesses:\n"
-                + unsolvedCloudBalance.toStringProcessList());
-
-        // Display the computer list
-        System.out.println("\nComputers:\n"
-                + unsolvedCloudBalance.toStringComputerList());
-
-        log.info("start to solve...");
-        CloudBalance solvedCloudBalance = solver.solve(unsolvedCloudBalance);
-
-        // Display the result
-        System.out.println("\nSolved cloudBalance with 3 computers and 12 processes:\n"
-                + toDisplayString(solvedCloudBalance));
-    }
-
-    public static String toDisplayString(CloudBalance cloudBalance) {
-        StringBuilder displayString = new StringBuilder();
-        for (CloudProcess process : cloudBalance.getProcessList()) {
-            CloudComputer computer = process.getComputer();
-            displayString.append("  ").append(process.getLabel()).append(" -> ")
-                    .append(computer == null ? null : computer.getLabel()).append("\n");
-        }
-        return displayString.toString();
-    }
-}

+ 0 - 30
src/main/java/com/rongwei/cloudbalancing/domain/AbstractPersistable.java

@@ -1,30 +0,0 @@
-package com.rongwei.cloudbalancing.domain;
-
-import org.optaplanner.core.api.domain.lookup.PlanningId;
-
-public abstract class AbstractPersistable {
-
-    protected Long id;
-
-    protected AbstractPersistable() {
-    }
-
-    protected AbstractPersistable(long id) {
-        this.id = id;
-    }
-
-    @PlanningId
-    public long getId() {
-        return id;
-    }
-
-    protected void setId(long id) {
-        this.id = id;
-    }
-
-    @Override
-    public String toString() {
-        return getClass().getName().replaceAll(".*\\.", "") + "-" + id;
-    }
-
-}

+ 0 - 76
src/main/java/com/rongwei/cloudbalancing/domain/CloudBalance.java

@@ -1,76 +0,0 @@
-package com.rongwei.cloudbalancing.domain;
-
-import lombok.*;
-import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;
-import org.optaplanner.core.api.domain.solution.PlanningScore;
-import org.optaplanner.core.api.domain.solution.PlanningSolution;
-import org.optaplanner.core.api.domain.solution.ProblemFactCollectionProperty;
-import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
-import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
-
-import java.util.List;
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@NoArgsConstructor
-@PlanningSolution
-public class CloudBalance extends AbstractPersistable {
-    @Getter(value = AccessLevel.NONE)
-    private List<CloudComputer> computerList;
-
-    @Getter(value = AccessLevel.NONE)
-    private List<CloudProcess> processList;
-
-    @Getter(value = AccessLevel.NONE)
-    private HardSoftScore score;
-
-    public CloudBalance(long id, List<CloudComputer> computerList, List<CloudProcess> processList) {
-        super(id);
-        this.computerList = computerList;
-        this.processList = processList;
-    }
-
-    @ValueRangeProvider
-    @ProblemFactCollectionProperty
-    public List<CloudComputer> getComputerList() {
-        return computerList;
-    }
-
-    @ValueRangeProvider
-    @PlanningEntityCollectionProperty
-    public List<CloudProcess> getProcessList() {
-        return processList;
-    }
-
-    @PlanningScore
-    public HardSoftScore getScore() {
-        return score;
-    }
-
-    public String toStringProcessList() {
-        StringBuilder displayString = new StringBuilder();
-        List<CloudProcess> processes = this.getProcessList();
-        for (CloudProcess process : processes) {
-            displayString.append(" ").append(process.getLabel()).append(" -> ")
-                    .append("requiredCpuPower: ").append(process.getRequiredCpuPower()).append("; ")
-                    .append("requiredMemory: ").append(process.getRequiredMemory()).append("; ")
-                    .append("requiredNetworkBandwidth: ").append(process.getRequiredMemory()).append("; ")
-                    .append("\n");
-        }
-        return displayString.toString();
-    }
-
-    public String toStringComputerList() {
-        StringBuilder displayString = new StringBuilder();
-        List<CloudComputer> computers = this.getComputerList();
-        for (CloudComputer computer : computers) {
-            displayString.append(" ").append(computer.getLabel()).append(" -> ")
-                    .append("cpuPower: ").append(computer.getCpuPower()).append("; ")
-                    .append("memory: ").append(computer.getMemory()).append("; ")
-                    .append("networkBandwidth: ").append(computer.getNetworkBandwidth()).append("; ")
-                    .append("cost: ").append(computer.getCost()).append("; ")
-                    .append("\n");
-        }
-        return displayString.toString();
-    }
-}

+ 0 - 31
src/main/java/com/rongwei/cloudbalancing/domain/CloudComputer.java

@@ -1,31 +0,0 @@
-package com.rongwei.cloudbalancing.domain;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@NoArgsConstructor
-public class CloudComputer extends AbstractPersistable {
-    private int cpuPower;
-    private int memory;
-    private int networkBandwidth;
-    private int cost;
-
-    public CloudComputer(long id, int cpuPower, int memory, int networkBandwidth, int cost) {
-        super(id);
-        this.cpuPower = cpuPower;
-        this.memory = memory;
-        this.networkBandwidth = networkBandwidth;
-        this.cost = cost;
-    }
-
-    public int getMultiplicand() {
-        return this.cpuPower * this.memory * this.networkBandwidth;
-    }
-
-    public String getLabel() {
-        return "Computer " + id;
-    }
-}

+ 0 - 40
src/main/java/com/rongwei/cloudbalancing/domain/CloudProcess.java

@@ -1,40 +0,0 @@
-package com.rongwei.cloudbalancing.domain;
-
-import com.rongwei.cloudbalancing.domain.solver.CloudComputerStrengthComparator;
-import com.rongwei.cloudbalancing.domain.solver.CloudProcessDifficultyComparator;
-import lombok.*;
-import org.optaplanner.core.api.domain.entity.PlanningEntity;
-import org.optaplanner.core.api.domain.variable.PlanningVariable;
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@NoArgsConstructor
-@PlanningEntity(difficultyComparatorClass = CloudProcessDifficultyComparator.class)
-public class CloudProcess extends AbstractPersistable {
-    private int requiredCpuPower;
-    private int requiredMemory;
-    private int requiredNetworkBandwidth;
-
-    @Getter(value = AccessLevel.NONE)
-    private CloudComputer computer;
-
-    public CloudProcess(long id, int requiredCpuPower, int requiredMemory, int requiredNetworkBandwidth) {
-        super(id);
-        this.requiredCpuPower = requiredCpuPower;
-        this.requiredMemory = requiredMemory;
-        this.requiredNetworkBandwidth = requiredNetworkBandwidth;
-    }
-
-    @PlanningVariable(strengthComparatorClass = CloudComputerStrengthComparator.class)
-    public CloudComputer getComputer() {
-        return computer;
-    }
-
-    public int getRequiredMultiplicand() {
-        return this.requiredCpuPower * this.requiredMemory * this.requiredNetworkBandwidth;
-    }
-
-    public String getLabel() {
-        return "Process " + id;
-    }
-}

+ 0 - 18
src/main/java/com/rongwei/cloudbalancing/domain/solver/CloudComputerStrengthComparator.java

@@ -1,18 +0,0 @@
-package com.rongwei.cloudbalancing.domain.solver;
-
-import com.rongwei.cloudbalancing.domain.CloudComputer;
-import static java.util.Comparator.comparingInt;
-import static java.util.Comparator.comparing;
-import java.util.Collections;
-import java.util.Comparator;
-
-public class CloudComputerStrengthComparator implements Comparator<CloudComputer> {
-    private static final Comparator<CloudComputer> COMPARATOR = comparingInt(CloudComputer::getMultiplicand)
-            .thenComparing(Collections.reverseOrder(comparing(CloudComputer::getCost)))
-            .thenComparingLong(CloudComputer::getId);
-
-    @Override
-    public int compare(CloudComputer a, CloudComputer b) {
-        return COMPARATOR.compare(a, b);
-    }
-}

+ 0 - 14
src/main/java/com/rongwei/cloudbalancing/domain/solver/CloudProcessDifficultyComparator.java

@@ -1,14 +0,0 @@
-package com.rongwei.cloudbalancing.domain.solver;
-
-import com.rongwei.cloudbalancing.domain.CloudProcess;
-import static java.util.Comparator.comparingInt;
-import java.util.Comparator;
-
-public class CloudProcessDifficultyComparator implements Comparator<CloudProcess> {
-    private static final Comparator<CloudProcess> COMPARATOR = comparingInt(CloudProcess::getRequiredMultiplicand)
-            .thenComparingLong(CloudProcess::getId);
-    @Override
-    public int compare(CloudProcess a, CloudProcess b) {
-        return COMPARATOR.compare(a, b);
-    }
-}

+ 0 - 235
src/main/java/com/rongwei/cloudbalancing/persistence/CloudBalancingGenerator.java

@@ -1,235 +0,0 @@
-package com.rongwei.cloudbalancing.persistence;
-
-import com.rongwei.cloudbalancing.domain.CloudBalance;
-import com.rongwei.cloudbalancing.domain.CloudComputer;
-import com.rongwei.cloudbalancing.domain.CloudProcess;
-import lombok.Getter;
-import lombok.extern.slf4j.Slf4j;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-@Slf4j
-public class CloudBalancingGenerator {
-    private static final int MAXIMUM_REQUIRED_CPU_POWER = 12; // in gigahertz
-    private static final int MAXIMUM_REQUIRED_MEMORY = 32; // in gigabyte RAM
-    private static final int MAXIMUM_REQUIRED_NETWORK_BANDWIDTH = 12; // in gigabyte per hour
-    protected Random random;
-
-    public CloudBalance createCloudBalance(int computerListSize, int processListSize) {
-        return createCloudBalance(determineFileName(computerListSize, processListSize),
-                computerListSize, processListSize);
-    }
-
-    private String determineFileName(int computerListSize, int processListSize) {
-        return computerListSize + "computers-" + processListSize + "processes";
-    }
-
-    public CloudBalance createCloudBalance(String inputId, int computerListSize, int processListSize) {
-        random = new Random(47);
-        List<CloudComputer> computerList = createComputerList(computerListSize);
-        List<CloudProcess> processList = createProcessList(processListSize);
-        CloudBalance cloudBalance = new CloudBalance(0, computerList, processList);
-        assureComputerCapacityTotalAtLeastProcessRequiredTotal(cloudBalance);
-        BigInteger possibleSolutionSize = BigInteger.valueOf(cloudBalance.getComputerList().size()).pow(
-                cloudBalance.getProcessList().size());
-        log.error("CloudBalance {} has {} computers and {} processes with a search space of {}.",
-                inputId, computerListSize, processListSize,
-                getFlooredPossibleSolutionSize(possibleSolutionSize));
-
-        return cloudBalance;
-    }
-
-    private List<CloudProcess> createProcessList(int processListSize) {
-        List<CloudProcess> processList = new ArrayList<>(processListSize);
-        for (int i = 0; i < processListSize; i++) {
-            CloudProcess process = generateProcess(i);
-            processList.add(process);
-        }
-        return processList;
-    }
-
-    private CloudProcess generateProcess(int id) {
-        int requiredCpuPower = generateRandom(MAXIMUM_REQUIRED_CPU_POWER);
-        int requiredMemory = generateRandom(MAXIMUM_REQUIRED_MEMORY);
-        int requiredNetworkBandwidth = generateRandom(MAXIMUM_REQUIRED_NETWORK_BANDWIDTH);
-        CloudProcess process = new CloudProcess(id, requiredCpuPower, requiredMemory, requiredNetworkBandwidth);
-        log.error("Created CloudProcess with requiredCpuPower ({}), requiredMemory ({}),"
-                        + " requiredNetworkBandwidth ({}).",
-                requiredCpuPower, requiredMemory, requiredNetworkBandwidth);
-        // Notice that we leave the PlanningVariable properties on null
-        return process;
-    }
-
-    private int generateRandom(int maximumValue) {
-        double randomDouble = random.nextDouble();
-        double parabolaBase = 2000.0;
-        double parabolaRandomDouble = (Math.pow(parabolaBase, randomDouble) - 1.0) / (parabolaBase - 1.0);
-        if (parabolaRandomDouble < 0.0 || parabolaRandomDouble >= 1.0) {
-            throw new IllegalArgumentException("Invalid generated parabolaRandomDouble (" + parabolaRandomDouble + ")");
-        }
-        int value = ((int) Math.floor(parabolaRandomDouble * maximumValue)) + 1;
-        if (value < 1 || value > maximumValue) {
-            throw new IllegalArgumentException("Invalid generated value (" + value + ")");
-        }
-        return value;
-    }
-
-    private List<CloudComputer> createComputerList(int computerListSize) {
-        List<CloudComputer> computerList = new ArrayList<>(computerListSize);
-        for (int i = 0; i < computerListSize; i++) {
-            CloudComputer computer = generateComputer(i);
-            computerList.add(computer);
-        }
-        return computerList;
-    }
-
-    private CloudComputer generateComputer(int id) {
-        int cpuPowerPricesIndex = random.nextInt(CPU_POWER_PRICES.length);
-        int memoryPricesIndex = distortIndex(cpuPowerPricesIndex, MEMORY_PRICES.length);
-        int networkBandwidthPricesIndex = distortIndex(cpuPowerPricesIndex, NETWORK_BANDWIDTH_PRICES.length);
-//        log.error("cpuIndex: {}, memoryIndex: {}, networkIndex: {}", cpuPowerPricesIndex, memoryPricesIndex, networkBandwidthPricesIndex);
-
-        int cost = CPU_POWER_PRICES[cpuPowerPricesIndex].getCost()
-                + MEMORY_PRICES[memoryPricesIndex].getCost()
-                + NETWORK_BANDWIDTH_PRICES[networkBandwidthPricesIndex].getCost();
-
-        CloudComputer computer = new CloudComputer(id, CPU_POWER_PRICES[cpuPowerPricesIndex].getHardwareValue(),
-                MEMORY_PRICES[memoryPricesIndex].getHardwareValue(),
-                NETWORK_BANDWIDTH_PRICES[networkBandwidthPricesIndex].getHardwareValue(),
-                cost);
-
-        log.error("Created computer with cpuPowerPricesIndex ({}), memoryPricesIndex ({}),"
-                        + " networkBandwidthPricesIndex ({}).",
-                cpuPowerPricesIndex, memoryPricesIndex, networkBandwidthPricesIndex);
-
-        return computer;
-    }
-
-    private int distortIndex(int referenceIndex, int length) {
-        int index = referenceIndex;
-        double randomDouble = random.nextDouble();
-        double loweringThreshold = 0.25;
-        while (randomDouble < loweringThreshold && index >= 1) {
-            index--;
-            loweringThreshold *= 0.10;
-        }
-        double heighteningThreshold = 0.75;
-        while (randomDouble >= heighteningThreshold && index <= (length - 2)) {
-            index++;
-            heighteningThreshold = (1.0 - ((1.0 - heighteningThreshold) * 0.10));
-        }
-        return index;
-    }
-
-    private static final Price[] CPU_POWER_PRICES = { // in gigahertz
-            new Price(3, "single core 3ghz", 110),
-            new Price(4, "dual core 2ghz", 140),
-            new Price(6, "dual core 3ghz", 180),
-            new Price(8, "quad core 2ghz", 270),
-            new Price(12, "quad core 3ghz", 400),
-            new Price(16, "quad core 4ghz", 1000),
-            new Price(24, "eight core 3ghz", 3000),
-    };
-
-    private static final Price[] MEMORY_PRICES = { // in gigabyte RAM
-            new Price(2, "2 gigabyte", 140),
-            new Price(4, "4 gigabyte", 180),
-            new Price(8, "8 gigabyte", 220),
-            new Price(16, "16 gigabyte", 300),
-            new Price(32, "32 gigabyte", 400),
-            new Price(64, "64 gigabyte", 600),
-            new Price(96, "96 gigabyte", 1000),
-    };
-
-    private static final Price[] NETWORK_BANDWIDTH_PRICES = { // in gigabyte per hour
-            new Price(2, "2 gigabyte", 100),
-            new Price(4, "4 gigabyte", 200),
-            new Price(6, "6 gigabyte", 300),
-            new Price(8, "8 gigabyte", 400),
-            new Price(12, "12 gigabyte", 600),
-            new Price(16, "16 gigabyte", 800),
-            new Price(20, "20 gigabyte", 1000),
-    };
-
-    @Getter
-    private static class Price {
-
-        private final int hardwareValue;
-        private final String description;
-        private final int cost;
-
-        private Price(int hardwareValue, String description, int cost) {
-            this.hardwareValue = hardwareValue;
-            this.description = description;
-            this.cost = cost;
-        }
-    }
-
-    private void assureComputerCapacityTotalAtLeastProcessRequiredTotal(CloudBalance cloudBalance) {
-        List<CloudComputer> computerList = cloudBalance.getComputerList();
-        int cpuPowerTotal = 0;
-        int memoryTotal = 0;
-        int networkBandwidthTotal = 0;
-        for (CloudComputer computer : computerList) {
-            cpuPowerTotal += computer.getCpuPower();
-            memoryTotal += computer.getMemory();
-            networkBandwidthTotal += computer.getNetworkBandwidth();
-        }
-        int requiredCpuPowerTotal = 0;
-        int requiredMemoryTotal = 0;
-        int requiredNetworkBandwidthTotal = 0;
-        for (CloudProcess process : cloudBalance.getProcessList()) {
-            requiredCpuPowerTotal += process.getRequiredCpuPower();
-            requiredMemoryTotal += process.getRequiredMemory();
-            requiredNetworkBandwidthTotal += process.getRequiredNetworkBandwidth();
-        }
-        int cpuPowerLacking = requiredCpuPowerTotal - cpuPowerTotal;
-        while (cpuPowerLacking > 0) {
-            CloudComputer computer = computerList.get(random.nextInt(computerList.size()));
-            int upgrade = determineUpgrade(cpuPowerLacking);
-            computer.setCpuPower(computer.getCpuPower() + upgrade);
-            cpuPowerLacking -= upgrade;
-        }
-        int memoryLacking = requiredMemoryTotal - memoryTotal;
-        while (memoryLacking > 0) {
-            CloudComputer computer = computerList.get(random.nextInt(computerList.size()));
-            int upgrade = determineUpgrade(memoryLacking);
-            computer.setMemory(computer.getMemory() + upgrade);
-            memoryLacking -= upgrade;
-        }
-        int networkBandwidthLacking = requiredNetworkBandwidthTotal - networkBandwidthTotal;
-        while (networkBandwidthLacking > 0) {
-            CloudComputer computer = computerList.get(random.nextInt(computerList.size()));
-            int upgrade = determineUpgrade(networkBandwidthLacking);
-            computer.setNetworkBandwidth(computer.getNetworkBandwidth() + upgrade);
-            networkBandwidthLacking -= upgrade;
-        }
-    }
-
-    private int determineUpgrade(int lacking) {
-        for (int upgrade : new int[]{8, 4, 2, 1}) {
-            if (lacking >= upgrade) {
-                return upgrade;
-            }
-        }
-        throw new IllegalStateException("Lacking (" + lacking + ") should be at least 1.");
-    }
-
-    public static String getFlooredPossibleSolutionSize(BigInteger possibleSolutionSize) {
-        if (possibleSolutionSize == null) {
-            return null;
-        }
-        if (possibleSolutionSize.compareTo(BigInteger.valueOf(1000L)) < 0) {
-            return possibleSolutionSize.toString();
-        }
-        BigDecimal possibleSolutionSizeBigDecimal = new BigDecimal(possibleSolutionSize);
-        int decimalDigits = possibleSolutionSizeBigDecimal.scale() < 0
-                ? possibleSolutionSizeBigDecimal.precision() - possibleSolutionSizeBigDecimal.scale()
-                : possibleSolutionSizeBigDecimal.precision();
-        return "10^" + decimalDigits;
-    }
-}

+ 0 - 63
src/main/java/com/rongwei/cloudbalancing/score/CloudBalancingConstraintProvider.java

@@ -1,63 +0,0 @@
-package com.rongwei.cloudbalancing.score;
-
-import com.rongwei.cloudbalancing.domain.CloudComputer;
-import com.rongwei.cloudbalancing.domain.CloudProcess;
-import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
-import org.optaplanner.core.api.score.stream.Constraint;
-import org.optaplanner.core.api.score.stream.ConstraintFactory;
-import org.optaplanner.core.api.score.stream.ConstraintProvider;
-
-import java.util.function.Function;
-
-import static org.optaplanner.core.api.score.stream.ConstraintCollectors.sum;
-import static org.optaplanner.core.api.score.stream.Joiners.equal;
-
-public class CloudBalancingConstraintProvider implements ConstraintProvider {
-    @Override
-    public Constraint[] defineConstraints(ConstraintFactory constraintFactory) {
-        return new Constraint[]{
-                requiredCpuPowerTotal(constraintFactory),
-                requiredMemoryTotal(constraintFactory),
-                requiredNetWorkBandWidthTotal(constraintFactory),
-                computerCost(constraintFactory)
-        };
-    }
-
-    // ************************************************************************
-    // Hard constraints
-    // ************************************************************************
-    private Constraint requiredCpuPowerTotal(ConstraintFactory constraintFactory) {
-        return constraintFactory.forEach(CloudProcess.class)
-                .groupBy(CloudProcess::getComputer, sum(CloudProcess::getRequiredCpuPower))
-                .filter((computer, requiredCpuPower) -> requiredCpuPower > computer.getCpuPower())
-                .penalize(HardSoftScore.ONE_HARD,
-                        (computer, requiredCpuPower) -> requiredCpuPower - computer.getCpuPower())
-                .asConstraint("requiredCpuPower");
-    }
-
-    private Constraint requiredMemoryTotal(ConstraintFactory constraintFactory) {
-        return constraintFactory.forEach(CloudProcess.class)
-                .groupBy(CloudProcess::getComputer, sum(CloudProcess::getRequiredMemory))
-                .filter((computer, requiredMemory) -> requiredMemory > computer.getMemory())
-                .penalize(HardSoftScore.ONE_HARD,
-                        (computer, requiredMemory) -> requiredMemory - computer.getMemory())
-                .asConstraint("requiredMemory");
-    }
-
-    private Constraint requiredNetWorkBandWidthTotal(ConstraintFactory constraintFactory) {
-        return constraintFactory.forEach(CloudProcess.class)
-                .groupBy(CloudProcess::getComputer, sum(CloudProcess::getRequiredNetworkBandwidth))
-                .filter((computer, requiredNetWorkBandWidth) -> requiredNetWorkBandWidth > computer.getNetworkBandwidth())
-                .penalize(HardSoftScore.ONE_HARD,
-                        (computer, requiredNetWorkBandWidth) -> requiredNetWorkBandWidth - computer.getNetworkBandwidth())
-                .asConstraint("requiredNetWorkBandWidth");
-    }
-
-    private Constraint computerCost(ConstraintFactory constraintFactory) {
-        return constraintFactory.forEach(CloudComputer.class)
-                .ifExists(CloudProcess.class, equal(Function.identity(), CloudProcess::getComputer))
-                .penalize(HardSoftScore.ONE_SOFT, CloudComputer::getCost)
-                .asConstraint("computerCost");
-    }
-
-}

+ 0 - 33
src/main/resources/logback.xml

@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-
-    <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <!-- %L lowers performance, %C and %c break indentation and therefore reduce readability, normal %t is verbose -->
-            <pattern>%d{HH:mm:ss.SSS} [%-12.12t] %-5p %m%n</pattern>
-        </encoder>
-    </appender>
-    <!--<appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
-    <!--<file>local/log/optaplanner.log</file>-->
-    <!--<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">-->
-    <!--<fileNamePattern>local/log/optaplanner.%i.log.zip</fileNamePattern>-->
-    <!--<minIndex>1</minIndex>-->
-    <!--<maxIndex>3</maxIndex>-->
-    <!--</rollingPolicy>-->
-    <!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">-->
-    <!--<maxFileSize>5MB</maxFileSize>-->
-    <!--</triggeringPolicy>-->
-    <!--<encoder>-->
-    <!--<pattern>%d{HH:mm:ss.SSS} [%t] %-5p %m%n</pattern>-->
-    <!--</encoder>-->
-    <!--</appender>-->
-
-    <!-- To override the debug log level from the command line, use the VM option "-Dlogback.level.org.optaplanner=trace" -->
-    <!--    <logger name="org.optaplanner" level="${logback.level.org.optaplanner:-debug}"/>-->
-
-    <root level="error">
-        <appender-ref ref="consoleAppender"/>
-        <!--<appender-ref ref="fileAppender" />-->
-    </root>
-
-</configuration>