Quellcode durchsuchen

Merge branch 'master' of http://192.168.1.220:10080/esb/esb

zhenglingfeng vor 8 Jahren
Ursprung
Commit
41cb7d4dfc
23 geänderte Dateien mit 414 neuen und 121 gelöschten Zeilen
  1. 206 29
      esb.iml
  2. 4 3
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/BrokerServerService.java
  3. 8 2
      hos-arbiter/src/main/resources/application.yml
  4. 8 1
      hos-broker/src/main/java/com/yihu/hos/broker/common/scheduler/MonitorScheduler.java
  5. 9 3
      hos-broker/src/main/java/com/yihu/hos/broker/models/ServiceMetrics.java
  6. 6 0
      hos-broker/src/main/java/com/yihu/hos/broker/services/ServiceMonitorService.java
  7. 3 0
      hos-broker/src/main/java/com/yihu/hos/broker/services/camel/CamelCompiler.java
  8. 49 15
      hos-broker/src/main/java/com/yihu/hos/broker/services/camel/ESBCamelService.java
  9. 5 4
      hos-broker/src/main/resources/application.yml
  10. 2 2
      hos-camel/src/main/java/api7/route/ApiRouteBulider.java
  11. 3 2
      hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java
  12. 3 3
      hos-rest/src/main/resources/spring/applicationContext.xml
  13. 2 1
      hos-saas/src/main/java/com/yihu/hos/saas/models/TenantModel.java
  14. 2 1
      hos-saas/src/main/java/com/yihu/hos/saas/models/TestModel.java
  15. 1 1
      hos-saas/src/main/java/com/yihu/hos/saas/models/UserModel.java
  16. 2 1
      hos-saas/src/main/java/com/yihu/hos/saas/models/UserTenantModel.java
  17. 13 5
      src/main/java/com/yihu/hos/monitor/controller/ServerMonitorController.java
  18. 5 3
      src/main/java/com/yihu/hos/monitor/controller/ServiceMonitorController.java
  19. 17 4
      src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java
  20. 7 2
      src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java
  21. 41 37
      src/main/java/com/yihu/hos/system/service/FlowManager.java
  22. 7 0
      src/main/java/com/yihu/hos/system/service/SystemManager.java
  23. 11 2
      src/main/java/com/yihu/hos/tenant/model/TenantSession.java

+ 206 - 29
esb.iml

@ -18,40 +18,12 @@
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
      <excludeFolder url="file://$MODULE_DIR$/target" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-core:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-spring-boot:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-spring:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-http4:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-http-common:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-jms:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-cxf:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-cxf-transport:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-soap:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-core:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-wsdl:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-databinding-jaxb:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-jaxrs:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-transports-http:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-jaxws:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-xml:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-simple:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-addr:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-policy:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-rs-security-oauth:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-rs-client:3.1.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-quartz:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-quartz2:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-xmljson:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-stream:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-jetty:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-jetty9:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.camel:camel-jetty-common:2.17.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-jasper:8.5.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.5" level="project" />
@ -226,4 +198,209 @@
    <orderEntry type="library" scope="TEST" name="Maven: org.json:json:20140107" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.3.RELEASE" level="project" />
  </component>
  <component name="org.twodividedbyzero.idea.findbugs">
    <option name="_basePreferences">
      <map>
        <entry key="property.analysisEffortLevel" value="default" />
        <entry key="property.analyzeAfterAutoMake" value="false" />
        <entry key="property.analyzeAfterCompile" value="false" />
        <entry key="property.annotationGutterIconEnabled" value="true" />
        <entry key="property.annotationSuppressWarningsClass" value="edu.umd.cs.findbugs.annotations.SuppressFBWarnings" />
        <entry key="property.annotationTextRangeMarkupEnabled" value="true" />
        <entry key="property.exportAsHtml" value="true" />
        <entry key="property.exportAsXml" value="true" />
        <entry key="property.exportBaseDir" value="" />
        <entry key="property.exportCreateArchiveDir" value="false" />
        <entry key="property.exportOpenBrowser" value="true" />
        <entry key="property.minPriorityToReport" value="Medium" />
        <entry key="property.runAnalysisInBackground" value="false" />
        <entry key="property.showHiddenDetectors" value="false" />
        <entry key="property.toolWindowToFront" value="true" />
      </map>
    </option>
    <option name="_detectors">
      <map>
        <entry key="AppendingToAnObjectOutputStream" value="true" />
        <entry key="AtomicityProblem" value="true" />
        <entry key="BadAppletConstructor" value="false" />
        <entry key="BadResultSetAccess" value="true" />
        <entry key="BadSyntaxForRegularExpression" value="true" />
        <entry key="BadUseOfReturnValue" value="true" />
        <entry key="BadlyOverriddenAdapter" value="true" />
        <entry key="BooleanReturnNull" value="true" />
        <entry key="BuildInterproceduralCallGraph" value="false" />
        <entry key="BuildObligationPolicyDatabase" value="true" />
        <entry key="BuildStringPassthruGraph" value="true" />
        <entry key="CallToUnsupportedMethod" value="false" />
        <entry key="CalledMethods" value="true" />
        <entry key="CheckCalls" value="false" />
        <entry key="CheckExpectedWarnings" value="false" />
        <entry key="CheckImmutableAnnotation" value="true" />
        <entry key="CheckRelaxingNullnessAnnotation" value="true" />
        <entry key="CheckTypeQualifiers" value="true" />
        <entry key="CloneIdiom" value="true" />
        <entry key="ComparatorIdiom" value="true" />
        <entry key="ConfusedInheritance" value="true" />
        <entry key="ConfusionBetweenInheritedAndOuterMethod" value="true" />
        <entry key="CovariantArrayAssignment" value="false" />
        <entry key="CrossSiteScripting" value="true" />
        <entry key="DefaultEncodingDetector" value="true" />
        <entry key="DoInsideDoPrivileged" value="true" />
        <entry key="DontCatchIllegalMonitorStateException" value="true" />
        <entry key="DontIgnoreResultOfPutIfAbsent" value="true" />
        <entry key="DontUseEnum" value="true" />
        <entry key="DroppedException" value="true" />
        <entry key="DumbMethodInvocations" value="true" />
        <entry key="DumbMethods" value="true" />
        <entry key="DuplicateBranches" value="true" />
        <entry key="EmptyZipFileEntry" value="false" />
        <entry key="EqualsOperandShouldHaveClassCompatibleWithThis" value="true" />
        <entry key="ExplicitSerialization" value="true" />
        <entry key="FieldItemSummary" value="true" />
        <entry key="FinalizerNullsFields" value="true" />
        <entry key="FindBadCast2" value="true" />
        <entry key="FindBadForLoop" value="true" />
        <entry key="FindBugsSummaryStats" value="true" />
        <entry key="FindCircularDependencies" value="false" />
        <entry key="FindComparatorProblems" value="true" />
        <entry key="FindDeadLocalStores" value="true" />
        <entry key="FindDoubleCheck" value="true" />
        <entry key="FindEmptySynchronizedBlock" value="true" />
        <entry key="FindFieldSelfAssignment" value="true" />
        <entry key="FindFinalizeInvocations" value="true" />
        <entry key="FindFloatEquality" value="true" />
        <entry key="FindFloatMath" value="false" />
        <entry key="FindHEmismatch" value="true" />
        <entry key="FindInconsistentSync2" value="true" />
        <entry key="FindJSR166LockMonitorenter" value="true" />
        <entry key="FindLocalSelfAssignment2" value="true" />
        <entry key="FindMaskedFields" value="true" />
        <entry key="FindMismatchedWaitOrNotify" value="true" />
        <entry key="FindNakedNotify" value="true" />
        <entry key="FindNoSideEffectMethods" value="true" />
        <entry key="FindNonSerializableStoreIntoSession" value="false" />
        <entry key="FindNonSerializableValuePassedToWriteObject" value="false" />
        <entry key="FindNonShortCircuit" value="true" />
        <entry key="FindNullDeref" value="true" />
        <entry key="FindNullDerefsInvolvingNonShortCircuitEvaluation" value="true" />
        <entry key="FindOpenStream" value="true" />
        <entry key="FindPuzzlers" value="true" />
        <entry key="FindRefComparison" value="true" />
        <entry key="FindReturnRef" value="true" />
        <entry key="FindRoughConstants" value="true" />
        <entry key="FindRunInvocations" value="true" />
        <entry key="FindSelfComparison" value="true" />
        <entry key="FindSelfComparison2" value="true" />
        <entry key="FindSleepWithLockHeld" value="true" />
        <entry key="FindSpinLoop" value="true" />
        <entry key="FindSqlInjection" value="true" />
        <entry key="FindTwoLockWait" value="true" />
        <entry key="FindUncalledPrivateMethods" value="true" />
        <entry key="FindUnconditionalWait" value="true" />
        <entry key="FindUninitializedGet" value="true" />
        <entry key="FindUnrelatedTypesInGenericContainer" value="true" />
        <entry key="FindUnreleasedLock" value="true" />
        <entry key="FindUnsatisfiedObligation" value="true" />
        <entry key="FindUnsyncGet" value="true" />
        <entry key="FindUseOfNonSerializableValue" value="true" />
        <entry key="FindUselessControlFlow" value="true" />
        <entry key="FindUselessObjects" value="true" />
        <entry key="FormatStringChecker" value="true" />
        <entry key="FunctionsThatMightBeMistakenForProcedures" value="true" />
        <entry key="HugeSharedStringConstants" value="true" />
        <entry key="IDivResultCastToDouble" value="true" />
        <entry key="IncompatMask" value="true" />
        <entry key="InconsistentAnnotations" value="true" />
        <entry key="InefficientIndexOf" value="false" />
        <entry key="InefficientInitializationInsideLoop" value="false" />
        <entry key="InefficientMemberAccess" value="false" />
        <entry key="InefficientToArray" value="false" />
        <entry key="InfiniteLoop" value="true" />
        <entry key="InfiniteRecursiveLoop" value="true" />
        <entry key="InheritanceUnsafeGetResource" value="true" />
        <entry key="InitializationChain" value="true" />
        <entry key="InitializeNonnullFieldsInConstructor" value="true" />
        <entry key="InstantiateStaticClass" value="true" />
        <entry key="IntCast2LongAsInstant" value="true" />
        <entry key="InvalidJUnitTest" value="true" />
        <entry key="IteratorIdioms" value="true" />
        <entry key="LazyInit" value="true" />
        <entry key="LoadOfKnownNullValue" value="true" />
        <entry key="LostLoggerDueToWeakReference" value="true" />
        <entry key="MethodReturnCheck" value="true" />
        <entry key="Methods" value="true" />
        <entry key="MultithreadedInstanceAccess" value="true" />
        <entry key="MutableEnum" value="true" />
        <entry key="MutableLock" value="true" />
        <entry key="MutableStaticFields" value="true" />
        <entry key="Naming" value="true" />
        <entry key="Noise" value="false" />
        <entry key="NoiseNullDeref" value="false" />
        <entry key="NoteAnnotationRetention" value="true" />
        <entry key="NoteCheckReturnValueAnnotations" value="true" />
        <entry key="NoteDirectlyRelevantTypeQualifiers" value="true" />
        <entry key="NoteJCIPAnnotation" value="true" />
        <entry key="NoteNonNullAnnotations" value="false" />
        <entry key="NoteNonnullReturnValues" value="false" />
        <entry key="NoteSuppressedWarnings" value="true" />
        <entry key="NoteUnconditionalParamDerefs" value="true" />
        <entry key="NumberConstructor" value="true" />
        <entry key="OptionalReturnNull" value="true" />
        <entry key="OverridingEqualsNotSymmetrical" value="true" />
        <entry key="PreferZeroLengthArrays" value="true" />
        <entry key="PublicSemaphores" value="false" />
        <entry key="QuestionableBooleanAssignment" value="true" />
        <entry key="ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass" value="true" />
        <entry key="ReadReturnShouldBeChecked" value="true" />
        <entry key="RedundantConditions" value="true" />
        <entry key="RedundantInterfaces" value="true" />
        <entry key="ReflectiveClasses" value="true" />
        <entry key="RepeatedConditionals" value="true" />
        <entry key="ResolveAllReferences" value="false" />
        <entry key="RuntimeExceptionCapture" value="true" />
        <entry key="SerializableIdiom" value="true" />
        <entry key="StartInConstructor" value="true" />
        <entry key="StaticCalendarDetector" value="true" />
        <entry key="StringConcatenation" value="true" />
        <entry key="SuperfluousInstanceOf" value="true" />
        <entry key="SuspiciousThreadInterrupted" value="true" />
        <entry key="SwitchFallthrough" value="true" />
        <entry key="SynchronizationOnSharedBuiltinConstant" value="true" />
        <entry key="SynchronizeAndNullCheckField" value="true" />
        <entry key="SynchronizeOnClassLiteralNotGetClass" value="true" />
        <entry key="SynchronizingOnContentsOfFieldToProtectField" value="true" />
        <entry key="TestASM" value="false" />
        <entry key="TestDataflowAnalysis" value="false" />
        <entry key="TestingGround" value="false" />
        <entry key="TestingGround2" value="false" />
        <entry key="TrainFieldStoreTypes" value="true" />
        <entry key="TrainLongInstantfParams" value="true" />
        <entry key="TrainNonNullAnnotations" value="true" />
        <entry key="TrainUnconditionalDerefParams" value="true" />
        <entry key="URLProblems" value="true" />
        <entry key="UncallableMethodOfAnonymousClass" value="true" />
        <entry key="UnnecessaryMath" value="true" />
        <entry key="UnreadFields" value="true" />
        <entry key="UselessSubclassMethod" value="false" />
        <entry key="VarArgsProblems" value="true" />
        <entry key="VolatileUsage" value="true" />
        <entry key="WaitInLoop" value="true" />
        <entry key="WrongMapIterator" value="true" />
        <entry key="XMLFactoryBypass" value="true" />
      </map>
    </option>
    <option name="_reportCategories">
      <map>
        <entry key="BAD_PRACTICE" value="true" />
        <entry key="CORRECTNESS" value="true" />
        <entry key="EXPERIMENTAL" value="true" />
        <entry key="I18N" value="true" />
        <entry key="MALICIOUS_CODE" value="true" />
        <entry key="MT_CORRECTNESS" value="true" />
        <entry key="PERFORMANCE" value="true" />
        <entry key="SECURITY" value="true" />
        <entry key="STYLE" value="true" />
      </map>
    </option>
  </component>
</module>

+ 4 - 3
hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/BrokerServerService.java

@ -55,10 +55,11 @@ public class BrokerServerService {
        update.set("port", brokerServer.getPort());
        update.set("updateTime", brokerServer.getUpdateTime());
        update.set("enable", brokerServer.isEnable());
        for (BrokerServer.ServiceFlow serviceFlow : brokerServer.getServiceFlows()) {
            update.addToSet("serviceFlows", serviceFlow);
        if (brokerServer.getServiceFlows()!=null) {
            for (BrokerServer.ServiceFlow serviceFlow : brokerServer.getServiceFlows()) {
                update.addToSet("serviceFlows", serviceFlow);
            }
        }
        WriteResult writeResult = mongoOperations.upsert(query, update, BrokerServer.class);
        if (writeResult.isUpdateOfExisting()) {
            //避免Broker重启的情况

+ 8 - 2
hos-arbiter/src/main/resources/application.yml

@ -26,7 +26,10 @@ arbiter:
      period: 10000
  central:
    url: http://127.0.0.1:10135
  terminal:
    url: http://127.0.0.1:10135
  tenant:
    name: jkzl
---
spring:
  profiles: test
@ -47,7 +50,10 @@ arbiter:
      period: 10000
  central:
    url: http://127.0.0.1:10135
  terminal:
    url: http://127.0.0.1:10135
  tenant:
    name: jkzl
---
spring:
  profiles: prod

+ 8 - 1
hos-broker/src/main/java/com/yihu/hos/broker/common/scheduler/MonitorScheduler.java

@ -15,6 +15,7 @@ import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.scheduling.annotation.Scheduled;
@ -35,6 +36,9 @@ import java.util.List;
@Component
public class MonitorScheduler {
    @Value("${hos.tenant.name}")
    private String tenant;
    @Autowired
    private MongoOperations mongoOperations;
@ -70,6 +74,7 @@ public class MonitorScheduler {
            MongodbUtil monoEnv = new MongodbUtil(MonitorConstant.MONITOR);
            Document result = null;
            result = new Document();
            result.put("tenant",tenant);
            result.put("create_date", DateUtil.getCurrentString(DateUtil.DEFAULT_YMDHMSDATE_FORMAT));
            result.put("create_time", new Date());
            result.put("host",host);
@ -145,7 +150,8 @@ public class MonitorScheduler {
        DBCollection envCollection = mongoOperations.getCollection(MonitorConstant.HOST);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("host", host)});
                        new BasicDBObject().append("host", host),
                        new BasicDBObject().append("tenant", tenant)});
        DBCursor cursor = envCollection.find(queryObject);
        if (cursor.size() < 1) {
@ -153,6 +159,7 @@ public class MonitorScheduler {
                Document result = new Document();
                String host = SigarUtil.getHost();
                String hostName = SigarUtil.getHostName();
                result.put("tenant",tenant);
                result.put("name",  hostName);
                result.put("host",  host);
                monoEnv.insert(MonitorConstant.HOST, result);

+ 9 - 3
hos-broker/src/main/java/com/yihu/hos/broker/models/ServiceMetrics.java

@ -1,11 +1,8 @@
package com.yihu.hos.broker.models;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
/**
 * @created Airhead 2016/8/8.
 */
@ -17,6 +14,15 @@ public class ServiceMetrics {
    private String name;
    private String value;
    private String createTime;
    private String tenant;
    public String getTenant() {
        return tenant;
    }
    public void setTenant(String tenant) {
        this.tenant = tenant;
    }
    public String getId() {
        return id;

+ 6 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/ServiceMonitorService.java

@ -10,6 +10,7 @@ import com.yihu.hos.broker.models.BusinessLog;
import com.yihu.hos.broker.models.ServiceMetrics;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.stereotype.Service;
@ -22,6 +23,10 @@ import java.util.*;
@Service("ServiceMonitorService")
public class ServiceMonitorService {
    public static final String BEAN_ID = "ServiceMonitorService";
    @Value("${hos.tenant.name}")
    private String tenant;
    @Autowired
    private MongoOperations mongoOperations;
@ -403,6 +408,7 @@ public class ServiceMonitorService {
    public void saveServiceMetrics(String name, String type, String value, String createTime) {
        ServiceMetrics serviceMetrics = new ServiceMetrics();
        serviceMetrics.setTenant(tenant);
        serviceMetrics.setName(name);
        serviceMetrics.setType(type);
        serviceMetrics.setValue(value);

+ 3 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/CamelCompiler.java

@ -36,8 +36,11 @@ public class CamelCompiler {
            //错误信息打印
            List diagnosticList = diagnostics.getDiagnostics();
            for (Object aDiagnosticList : diagnosticList) {
                System.out.println(aDiagnosticList.toString());
                logger.error(aDiagnosticList.toString());
            }
        }else {
            System.out.println("编译成功"+sourcePath);
        }
        return success;

+ 49 - 15
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/ESBCamelService.java

@ -1,7 +1,10 @@
package com.yihu.hos.broker.services.camel;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import com.mongodb.client.result.DeleteResult;
import com.yihu.hos.broker.configurations.MongoConfiguration;
import com.yihu.hos.core.constants.CoreConstant;
import com.yihu.hos.core.datatype.ClassFileUtil;
@ -13,6 +16,7 @@ import com.yihu.hos.web.framework.model.bo.ServiceFlow;
import com.yihu.hos.web.framework.util.GridFSUtil;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -45,6 +49,8 @@ public class ESBCamelService {
    @Autowired
    private MongoConfiguration mongoConfig;
    private String dbName = "upload";
    private String serviceFlow = "serviceFlow";
    private String configuration = "configuration";
    @Autowired
    private ObjectMapper objectMapper;
@ -80,6 +86,7 @@ public class ESBCamelService {
            logger.debug("start camel router success," + serviceFlow.getRouteCode());
            return Result.error("服务流程增加成功!");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e);
            return Result.error("服务流程增加失败!");
        }
@ -112,6 +119,7 @@ public class ESBCamelService {
            return Result.error("服务流程变更增加成功!");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e);
            return Result.error("服务流程变更增加失败!");
        }
@ -146,12 +154,17 @@ public class ESBCamelService {
            if (serviceFlowValid.is()) return Result.error("必要的入参数据不正确,请检查!");
            ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
            ServiceFlow.HandleFile handleFile = serviceFlowValid.getHandleFile();
            String routeCode = serviceFlow.getRouteCode();
            SystemCamelContext.getContext().stopRoute(routeCode);
            SystemCamelContext.getContext().removeRoute(routeCode);
            this.deleteClassFile(handleFile);  //清理文件?
            ArrayList<ServiceFlow.HandleFile> handleFiles =  serviceFlowValid.getHandleFiles();
            if (handleFiles!=null) {
                for (ServiceFlow.HandleFile handleFile : handleFiles) {
                    String routeCode = serviceFlow.getRouteCode();
                    SystemCamelContext.getContext().stopRoute(routeCode);
                    SystemCamelContext.getContext().removeRoute(routeCode);
                    this.deleteClassFile(handleFile);  //清理文件?
                    this.deleteServiceFlow(handleFile.getRouteCode());//删除mongo中serviceFlow信息
                    //TODO 删除mongodb中文件
                }
            }
            return Result.success("服务流程删除成功!");
        } catch (Exception e) {
            return Result.error("服务流程删除失败!");
@ -247,24 +260,45 @@ public class ESBCamelService {
        String sourcePath = ClassFileUtil.getFilePath(resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.JAVA_FILE);
        logger.info(sourcePath);
        return CamelCompiler.compile(sourcePath, resource.toString());
        boolean succ = CamelCompiler.compile(sourcePath, resource.getPath());
        if (succ){
            //编译成功后将class文件上传至mongodb;文件名为类名+ routeCode
            String packagePath = StringUtil.replaceStrAll(handleFile.getPackageName(), ".", "/");
            String classPath =  resource.getPath()+ packagePath + "/" + handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
            GridFSUtil.uploadFile(dbName, classPath, handleFile.getClassName()+handleFile.getRouteCode() + ClassFileUtil.CLASS_FILE);
        }
        return succ;
    }
    private void deleteClassFile(ServiceFlow.HandleFile handleFile) {
        String className = SystemCamelContext.getClassMapping(handleFile.getRouteCode(), handleFile.getClassName(), handleFile.getUsage());
        if (StringUtil.isEmpty(className)) {
            return;
        }
//        String className = SystemCamelContext.getClassMapping(handleFile.getRouteCode(), handleFile.getClassName(), handleFile.getUsage());
//        if (StringUtil.isEmpty(className)) {
//            return;
//        }
        String packagePath = StringUtil.replaceStrAll(handleFile.getPackageName(), ".", "/");
        String classPath = ClassLoader.getSystemResource("").getPath() + "/" + packagePath + "/" + className + ".class";
        String javaPath = ClassLoader.getSystemResource("").getPath() + "/" + packagePath + "/" + className + ".java";
        String classPath = ClassLoader.getSystemResource("").getPath() + "/" + packagePath + "/" + handleFile.getClassName() + ".class";
        String javaPath = ClassLoader.getSystemResource("").getPath() + "/" + packagePath + "/" + handleFile.getClassName() + ".java";
        ClassFileUtil.deleteClassfile(classPath);
        ClassFileUtil.deleteClassfile(javaPath);
        // 完成
        logger.info("===================" + handleFile.getPackageName() + CoreConstant.DOT + className + ".class 删除过程结束");
        logger.info("===================" + handleFile.getPackageName() + CoreConstant.DOT + handleFile.getClassName() + ".class 删除过程结束");
    }
    /**
     *  删除 serviceFlow记录
     * @param routeCode
     */
    private void deleteServiceFlow(String routeCode){
        try {
            MongoDatabase db = mongoConfig.mongoClient().getDatabase(configuration);
            MongoCollection<Document> collection = db.getCollection(serviceFlow);
            DeleteResult result = collection.deleteMany(Filters.eq("routeCode",routeCode));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void addRouter(ArrayList<ServiceFlow.HandleFile> handleFiles) throws Exception {

+ 5 - 4
hos-broker/src/main/resources/application.yml

@ -19,9 +19,9 @@ spring:
  profiles: dev
  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://192.168.1.220:3306/esb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
    username: hos2
    password: hos2
    url: jdbc:mysql://192.168.1.220:8066/hos1?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
    username: hos
    password: 123456
    test-on-borrow: true
    validation-query: SELECT 1
    test-while-idle: true
@ -51,7 +51,8 @@ hos:
    url: http://localhost:10135
  timer:
      period: 10000
  tenant:
    name: jkzl
---
spring:

+ 2 - 2
hos-camel/src/main/java/api7/route/ApiRouteBulider.java

@ -7,7 +7,7 @@ import org.apache.camel.builder.RouteBuilder;
public class ApiRouteBulider extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("jetty:http://localhost:9097/api/v1").routeId("api7").log("servers: 0,code: ,order: 0")
                .process(new ApiProcessor()).log("servers: 0,code: ,order: 0");
        from("jetty:http://localhost:9097/api/v1").routeId("api7")
                .process(new ApiProcessor()).log("servers: 0,code: ,order: 0").log("servers: 0,code: ,order: 0");
    }
}

+ 3 - 2
hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java

@ -90,11 +90,12 @@ public class ClassFileUtil {
    public static Boolean deleteClassfile(String classPath) {
        // 开始输出文件内容
        try {
            boolean succ = false;
            File file = new File(classPath);
            if (file.isFile() && file.exists()) {
                file.delete();
                succ = file.delete();
            }
            return true;
            return succ;
        } catch (Exception e) {
            return false;
        }

+ 3 - 3
hos-rest/src/main/resources/spring/applicationContext.xml

@ -24,9 +24,9 @@
    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://192.168.1.220:3306/esb?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos2"/>
        <property name="password" value="hos2"/>
        <property name="url" value="jdbc:mysql://192.168.1.220:8066/hos1?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos"/>
        <property name="password" value="123456"/>
        <property name="initialSize" value="1"/>
        <property name="maxTotal" value="100"/>
        <property name="maxIdle" value="50"/>

+ 2 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/TenantModel.java

@ -1,6 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/TestModel.java

@ -1,6 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 1 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/UserModel.java

@ -1,7 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 2 - 1
hos-saas/src/main/java/com/yihu/hos/saas/models/UserTenantModel.java

@ -1,6 +1,7 @@
package com.yihu.hos.saas.models;
import com.yihu.hos.saas.models.common.IdModel;
import com.yihu.hos.tenant.models.common.IdModel;
import javax.persistence.Column;
import javax.persistence.Entity;

+ 13 - 5
src/main/java/com/yihu/hos/monitor/controller/ServerMonitorController.java

@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
 * @author HZY
@ -39,6 +41,7 @@ public class ServerMonitorController {
    @ResponseBody
    @ApiOperation(value = "获取服务器使用率", produces = "application/json", notes = "获取服务器硬件使用率")
    public Result usage(
            HttpServletRequest request,
            @ApiParam(name = "host", value = "服务器IP", required = true)
            @RequestParam(value = "host") String host,
            @ApiParam(name = "type", value = "类型", required = true)
@ -47,7 +50,8 @@ public class ServerMonitorController {
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        return monitorService.getMonitorList(host,type, beginTime, endTime);
        HttpSession session = request.getSession();
            return monitorService.getMonitorList(session,host,type, beginTime, endTime);
    }
@ -55,19 +59,22 @@ public class ServerMonitorController {
    @ResponseBody
    @ApiOperation(value = "获取服务器详情信息", produces = "application/json", notes = "获取服务器详情信息")
    public Result detail(
            HttpServletRequest request,
            @ApiParam(name = "host", value = "服务器IP", required = true)
            @RequestParam(value = "host") String host,
            @ApiParam(name = "type", value = "类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "date", value = "时间点", required = true)
            @RequestParam(value = "date") String date) {
        return monitorService.getMonitorDetail(host,type, date);
        HttpSession session = request.getSession();
        return monitorService.getMonitorDetail(session,host,type, date);
    }
    @RequestMapping(value = "/hosts", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务器列表", produces = "application/json", notes = "获取服务器列表")
    public Result hosts() {
    public Result hosts(HttpServletRequest request) {
        HttpSession session = request.getSession();
        return monitorService.getHosts();
    }
@ -75,9 +82,10 @@ public class ServerMonitorController {
    @RequestMapping(value = "/trees", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务器树列表", produces = "application/json", notes = "获取服务器树列表")
    public Result trees() {
    public Result trees(HttpServletRequest request) {
        try {
            return monitorService.getServerTreeList();
            HttpSession session = request.getSession();
            return monitorService.getServerTreeList(session);
        } catch (Exception e) {
            return Result.error("获取服务树列表失败");
        }

+ 5 - 3
src/main/java/com/yihu/hos/monitor/controller/ServiceMonitorController.java

@ -1,6 +1,5 @@
package com.yihu.hos.monitor.controller;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.monitor.service.ServiceMonitorService;
import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.ApiOperation;
@ -13,7 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
 * @author HZY
@ -40,6 +40,7 @@ public class ServiceMonitorController {
    @ResponseBody
    @ApiOperation(value = "获取服务指标", produces = "application/json", notes = "获取服务指标")
    public Result metrics(
            HttpServletRequest request,
            @ApiParam(name = "id", value = "serviceID", required = true)
            @RequestParam(value = "id") String id,
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
@ -47,7 +48,8 @@ public class ServiceMonitorController {
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        try {
            return monitorService.metrics(id, beginTime, endTime);
            HttpSession session = request.getSession();
            return monitorService.metrics(session,id, beginTime, endTime);
        } catch (Exception e) {
            return Result.error("获取服务指标失败");
        }

+ 17 - 4
src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java

@ -1,7 +1,9 @@
package com.yihu.hos.monitor.service;
import com.mongodb.*;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.tenant.model.TenantSession;
import com.yihu.hos.web.framework.model.ActionResult;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.model.TreeView;
@ -11,6 +13,7 @@ import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -32,11 +35,13 @@ public class ServerMonitorService {
    @Autowired
    private Mongo mongo;
    public Result getMonitorList(String host, String type, String beginTime, String endTime) {
    public Result getMonitorList(HttpSession session,String host, String type, String beginTime, String endTime) {
        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
        mongoOperations = new MongoTemplate(mongo, MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(SERVER);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("tenant",tenantSession.getTenant()),
                        new BasicDBObject().append("host",host),
                        new BasicDBObject().append("type",type),
                        new BasicDBObject().append("create_time",
@ -57,11 +62,13 @@ public class ServerMonitorService {
        return actionResult;
    }
    public Result getMonitorDetail(String host, String type, String date) {
    public Result getMonitorDetail(HttpSession session,String host, String type, String date) {
        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
        mongoOperations = new MongoTemplate(mongo, MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(SERVER);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("tenant",tenantSession.getTenant()),
                        new BasicDBObject().append("host", host),
                        new BasicDBObject().append("type", type),
                        new BasicDBObject().append("create_time",new BasicDBObject().append(QueryOperators.LTE, DateUtil.toTimestamp(date)))});
@ -104,11 +111,17 @@ public class ServerMonitorService {
     * @return
     * @throws Exception
     */
    public Result getServerTreeList() throws Exception {
    public Result getServerTreeList(HttpSession session) throws Exception {
        List<TreeView> treeList = new ArrayList<>();
        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
        mongoOperations = new MongoTemplate(mongo, MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(HOST);
        DBCursor cursor = envCollection.find();
        //查询条件
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("tenant",tenantSession.getTenant())});
        DBCursor cursor = envCollection.find(queryObject);
        while(cursor.hasNext()) {
            DBObject dbObject = cursor.next();

+ 7 - 2
src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java

@ -1,11 +1,13 @@
package com.yihu.hos.monitor.service;
import com.mongodb.*;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.core.datatype.CollectionUtil;
import com.yihu.hos.monitor.dao.ServiceMonitorDao;
import com.yihu.hos.system.model.SystemServiceEndpoint;
import com.yihu.hos.system.model.SystemServiceFlow;
import com.yihu.hos.system.model.SystemServiceFlowConfig;
import com.yihu.hos.tenant.model.TenantSession;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.model.TreeView;
@ -16,6 +18,7 @@ import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -39,10 +42,11 @@ public class ServiceMonitorService {
    @Autowired
    private ServiceMonitorDao serviceMonitorDao;
    public Result metrics(String id, String beginTime, String endTime) throws Exception {
    public Result metrics(HttpSession session,String id, String beginTime, String endTime) throws Exception {
        String name;
        String code;
        String description;
        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
        if (id.contains("flow")) {
            Integer flowId = Integer.parseInt(id.replace("flow", ""));
            SystemServiceFlow systemServiceFlow = serviceMonitorDao.getFlowById(flowId);
@ -68,7 +72,8 @@ public class ServiceMonitorService {
                                new BasicDBObject().append(QueryOperators.GTE, beginTime)),
                        new BasicDBObject().append("createTime",
                                new BasicDBObject().append(QueryOperators.LT, endTime)),
                        new BasicDBObject("name", code)});
                        new BasicDBObject("name", code),
                        new BasicDBObject("tenant", tenantSession.getTenant())});
        JSONObject result = new JSONObject();
        DBCursor cursor = metrics.find(queryObject);

+ 41 - 37
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -186,28 +186,6 @@ public class FlowManager implements IFlowManage {
            serviceFlowList.add(serviceFlow);
        }
        List<SystemServiceFlow> javaFlowList = flowDao.getFlowList(ServiceFlowConstant.JAVA);
        for (SystemServiceFlow systemServiceFlow : javaFlowList) {
            ServiceFlow serviceFlow = new ServiceFlow();
            serviceFlow.setRouteCode(systemServiceFlow.getCode());
            List<SystemServiceFlowTemp> tempList = flowTempDao.getFlowTempByFlowId(systemServiceFlow.getId());
            ArrayList<ServiceFlow.HandleFile> handleFileList = new ArrayList<>();
            for (SystemServiceFlowTemp flowTemp : tempList) {
                ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                handleFile.setFileType(ServiceFlowConstant.JAVA);
                handleFile.setClassName(flowTemp.getClassName());
                handleFile.setPackageName(flowTemp.getPackageName());
                handleFile.setFilePath(flowTemp.getClassPath());
                handleFile.setUsage(flowTemp.getType());
                handleFileList.add(handleFile);
            }
            serviceFlow.setHandleFiles(handleFileList);
            serviceFlowList.add(serviceFlow);
        }
        return serviceFlowList;
    }
@ -346,18 +324,29 @@ public class FlowManager implements IFlowManage {
    public Result deleteFlow(Integer id) throws Exception {
        SystemServiceFlow flow = flowDao.getEntity(SystemServiceFlow.class, id);
        if (flow == null){ return Result.error("删除流程失败");}
        ArrayList<ServiceFlow.HandleFile>  handleFiles =new ArrayList<>();
        List<SystemServiceFlowClass> flowClassList = flowClassDao.getFlowClassByFlowId(id);
        if (ServiceFlowConstant.JAVA.equals(flow.getFileType())) {
            flowTempDao.deleteFlowTempByFlowId(id);
        } else {
            for (SystemServiceFlowClass flowClass : flowClassList) {
                flowClassDao.deleteEntity(flowClass);
            }
            ServiceFlow serviceFlow = new ServiceFlow();
            serviceFlow.setRouteCode(flow.getCode());
            serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
            for (SystemServiceFlowClass flowClass : flowClassList) {
                ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                handleFile.setRouteCode(flow.getCode());
                handleFile.setFileType(ServiceFlowConstant.JAVA);
                handleFile.setPackageName(flowClass.getPackageName());
                handleFile.setClassName(flowClass.getClassName());
                handleFile.setFilePath(flowClass.getClassPath());
                handleFile.setUsage(flowClass.getType());
                handleFiles.add(handleFile);
                flowClassDao.deleteEntity(flowClass);
            }
            serviceFlow.setHandleFiles(handleFiles);
            serviceFlowEventService.serviceFlowDelete(serviceFlow);
        }
        flowDao.deleteEntity(flow);
@ -550,17 +539,24 @@ public class FlowManager implements IFlowManage {
                }
            }
            String deName = DES.decrypt(flowTemp.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
            //生成新的route文件
            String newFileName = genRouteJavaFile(flow.getCode(), flowTemp.getClassName(), deName, newCron);
            String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
            ServiceFlow serviceFlow = new ServiceFlow();
            serviceFlow.setRouteCode(flow.getCode());
            serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
            ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
            handleFile.setRouteCode(flow.getCode());
            handleFile.setFileType(ServiceFlowConstant.JAVA);
            handleFile.setPackageName(flowTemp.getClassPath());
            handleFile.setClassName(flowTemp.getClassName());
            handleFile.setFilePath(basePath.toString());
            handleFile.setPackageName(basePath.toString());
            handleFile.setClassName(flowTemp.getClassName()+flow.getCode());
            handleFile.setFilePath(enNewFileName);
            handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
            ArrayList<ServiceFlow.HandleFile>  handleFiles =new ArrayList<>();
            handleFiles.add(handleFile);
            serviceFlow.setHandleFiles(handleFiles);
            serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
            return flowId;
        }
@ -597,18 +593,22 @@ public class FlowManager implements IFlowManage {
            newFlowClass.setIsUpdate("1");
            //生成新的route文件
            String newFileName = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), deName, newCron);
            String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
            if (newFileName != null) {
                ServiceFlow serviceFlow = new ServiceFlow();
                serviceFlow.setRouteCode(newFlow.getCode());
                serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
                ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                handleFile.setRouteCode(newFlow.getCode());
                handleFile.setFileType(ServiceFlowConstant.CLASS);
                handleFile.setFileType(ServiceFlowConstant.JAVA);
                handleFile.setPackageName(flowTemp.getPackageName());
                handleFile.setClassName(flowTemp.getClassName());
                handleFile.setFilePath(newFileName);
                handleFile.setClassName(flowTemp.getClassName()+newFlow.getCode());
                handleFile.setFilePath(enNewFileName);
                handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
                ArrayList<ServiceFlow.HandleFile>  handleFiles =new ArrayList<>();
                handleFiles.add(handleFile);
                serviceFlow.setHandleFiles(handleFiles);
                serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
                return newFlow.getId();
            } else {
@ -637,6 +637,7 @@ public class FlowManager implements IFlowManage {
            newFlow.setCreateDate(new Date());
            newFlow.setFileType(ServiceFlowConstant.CLASS);
            flowDao.saveEntity(newFlow);
            ArrayList<ServiceFlow.HandleFile>  handleFiles =new ArrayList<>();
            //新增processor记录
            for (SystemServiceFlowTemp process : flowTempProces) {
@ -662,6 +663,8 @@ public class FlowManager implements IFlowManage {
                processClass.setIsUpdate("1");
                //生成新的java文件
                String newFileName = genProcessorJavaFile(jobId, newFlow.getCode(), deName, processClass.getClassName());
                String enNewFileName = DES.encrypt(newFileName,DES.COMMON_PASSWORD);
                if (newFileName != null) {
                    //发送消息
                    ServiceFlow serviceFlow = new ServiceFlow();
@ -669,12 +672,13 @@ public class FlowManager implements IFlowManage {
                    serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
                    ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                    handleFile.setRouteCode(newFlow.getCode());
                    handleFile.setFileType(ServiceFlowConstant.CLASS);
                    handleFile.setFileType(ServiceFlowConstant.JAVA);
                    handleFile.setPackageName(processClass.getPackageName());
                    handleFile.setClassName(processClass.getClassName());
                    handleFile.setFilePath(newFileName);
                    handleFile.setFilePath(enNewFileName);
                    handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
                    handleFiles.add(handleFile);
                    serviceFlow.setHandleFiles(handleFiles);
                    serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
                    flowClassDao.saveEntity(processClass);
                } else {

+ 7 - 0
src/main/java/com/yihu/hos/system/service/SystemManager.java

@ -1,5 +1,7 @@
package com.yihu.hos.system.service;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.tenant.model.TenantSession;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.system.model.SystemUser;
import com.yihu.hos.system.service.intf.ISystemManager;
@ -25,6 +27,7 @@ public class SystemManager implements ISystemManager {
    @Override
    public  Result loginAction(HttpSession session,String user,String password) throws Exception
    {
        TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
        //特殊账户
        if(user.equals("admin") && password.equals("JKZL"))
        {
@ -32,6 +35,8 @@ public class SystemManager implements ISystemManager {
            userInfo.setLoginCode("admin");
            userInfo.setUserName("管理员");
            session.setAttribute("userInfo",userInfo);
            tenantSession.setUserCode("admin");
            session.setAttribute(ContextAttributes.TENANT_SESSION, tenantSession);
            return Result.success("登录成功!");
        }
@ -46,6 +51,8 @@ public class SystemManager implements ISystemManager {
            String userPassword = userInfo.getPassword();
            if(userPassword.equals(DigestUtils.md5Hex(password + saltValue)))
            {
                tenantSession.setUserCode(user);
                session.setAttribute(ContextAttributes.TENANT_SESSION, tenantSession);
                session.setAttribute("userInfo",userInfo);
                return Result.success("登录成功!");
            }

+ 11 - 2
src/main/java/com/yihu/hos/tenant/model/TenantSession.java

@ -9,12 +9,13 @@ public class TenantSession {
    private String userCode;
    private String token;
    private String schema;
    private String tenant;
    public TenantSession() {
    }
    public TenantSession(String userCode, String schema) {
        this.userCode = userCode;
    public TenantSession(String tenant, String schema) {
        this.tenant = tenant;
        this.schema = schema;
        token = UUID.randomUUID().toString();
    }
@ -48,4 +49,12 @@ public class TenantSession {
    public void setToken(String token) {
        this.token = token;
    }
    public String getTenant() {
        return tenant;
    }
    public void setTenant(String tenant) {
        this.tenant = tenant;
    }
}