提交 426db155 编写于 作者: ibizdev's avatar ibizdev

chitanda 部署微服务应用 [TrainSys,网页端]

上级 a78b7d2f
流水线 #3280 已取消 ,包含阶段
import keys from './raw-material-keys';
import { IContext, IEntityLocalDataService, IParams } from 'ibiz-core';
import { GlobalService } from '../../service';
import { IRawMaterial } from '../interface';
/**
* RawMaterialDTOdto辅助类
*
* @export
* @class RawMaterialDTOHelp
*/
export class RawMaterialDTOHelp {
/**
* 获取数据服务
*
* @param {IContext} context 应用上下文对象
* @returns {*}
* @memberof RawMaterialDTOHelp
*/
public static async getService(context: IContext): Promise<IEntityLocalDataService<IRawMaterial>> {
return new GlobalService().getService('RawMaterial',context);
}
/**
* DTO转化成数据对象
*
* @param {IContext} context 应用上下文对象
* @param {IParams} source dto对象
* @returns {*}
* @memberof RawMaterialDTOHelp
*/
public static async ToDataObj(context: IContext, source: IParams) {
const _data: any = {};
// 建立时间
_data.createdate = source.createdate;
// 建立人
_data.createman = source.createman;
// 原材料标识
_data.rawmaterialid = source.rawmaterialid;
// 原材料名称
_data.rawmaterialname = source.rawmaterialname;
// 更新时间
_data.updatedate = source.updatedate;
// 更新人
_data.updateman = source.updateman;
// 处理预置字段(以srf开头)
if(source && Object.keys(source).length >0){
Object.keys(source).forEach((key:string) =>{
if(key.startsWith('srf')){
_data[key] = source[key];
}
})
}
return _data;
}
/**
* 转化数组(dto转化成数据对象)
*
* @param {IContext} context 应用上下文对象
* @param {any[]} data 数据对象
* @returns {any[]}
* @memberof RawMaterialDTOHelp
*/
public static async ToDataObjArray(context: IContext, data: any[]) {
const _data: any[] = [];
if (data && Array.isArray(data) && data.length > 0) {
for (let i = 0; i < data.length; i++) {
const tempdata = await this.ToDataObj(context, data[i]);
_data.push(tempdata);
}
}
return _data;
}
/**
* 数据对象转化成DTO
*
* @param {IContext} context 应用上下文对象
* @param {*} source 数据对象
* @returns {*}
* @memberof RawMaterialDTOHelp
*/
public static async ToDto(context: IContext, source: IParams) {
const _data: any = {};
const excludes: string[] = [];
// 建立时间
_data.createdate = source.createdate;
// 建立人
_data.createman = source.createman;
// 原材料标识
_data.rawmaterialid = source.rawmaterialid;
// 原材料名称
_data.rawmaterialname = source.rawmaterialname;
// 更新时间
_data.updatedate = source.updatedate;
// 更新人
_data.updateman = source.updateman;
// 附加额外数据
if (source && Object.keys(source).length > 0 && keys) {
Object.keys(source).forEach((key: string) => {
if (!keys.includes(key) && !excludes.includes(key)) {
_data[key] = source[key];
}
})
}
return _data;
}
/**
* 转化数组(数据对象转化成dto)
*
* @param {IContext} context 应用上下文对象
* @param {any[]} data
* @returns {any[]}
* @memberof RawMaterialDTOHelp
*/
public static async ToDtoArray(context: IContext, data: any[]) {
const _data: any[] = [];
if (data && Array.isArray(data) && data.length > 0) {
for (let i = 0; i < data.length; i++) {
const tempdata = await this.ToDto(context, data[i]);
_data.push(tempdata);
}
}
return _data;
}
/**
* 处理响应dto对象
*
* @param {*} context 应用上下文对象
* @param {*} data 响应dto对象
* @returns {*}
* @memberof RawMaterialDTOHelp
*/
public static async set(context: IContext, data: any) {
const _data: IParams = await this.ToDataObj(context, data);
return _data;
}
/**
* 处理请求数据对象
*
* @param {*} context 应用上下文对象
* @param {*} data 数据对象
* @returns {*}
* @memberof RawMaterialDTOHelp
*/
public static async get(context: IContext, data: any = {}) {
return await this.ToDto(context, data);
}
/**
* 获取缓存数据
*
* @param {*} context 应用上下文对象
* @param {*} srfkey 数据主键
* @returns {*}
* @memberof RawMaterialDTOHelp
*/
public static async getCacheData(context: IContext, srfkey: string) {
const targetService: IEntityLocalDataService<IRawMaterial> = await this.getService(context);
const result = await targetService.getLocal(context, srfkey);
if(result){
return await this.ToDto(context,result);
}
}
/**
* 获取缓存数组
*
* @param {*} context 应用上下文对象
* @returns {any[]}
* @memberof RawMaterialDTOHelp
*/
public static async getCacheDataArray(context: IContext) {
const targetService: IEntityLocalDataService<IRawMaterial> = await this.getService(context);
const result = await targetService.getLocals(context);
if(result && result.length >0){
return await this.ToDtoArray(context,result);
}else{
return [];
}
}
/**
* 设置缓存数据
*
* @param {*} context 应用上下文对象
* @param {any} data 数据
* @returns {any[]}
* @memberof RawMaterialDTOHelp
*/
public static async setCacheData(context: IContext, data: any) {
const targetService: IEntityLocalDataService<IRawMaterial> = await this.getService(context);
const _data: any = await this.set(context, data);
await targetService.addLocal(context, _data);
}
/**
* 设置缓存数组
*
* @param {*} context 应用上下文对象
* @param {any[]} data 数据
* @returns {any[]}
* @memberof RawMaterialDTOHelp
*/
public static async setCacheDataArray(context: IContext, data: any[]) {
if (data && data.length > 0) {
const targetService: IEntityLocalDataService<IRawMaterial> = await this.getService(context);
for (let i = 0; i < data.length; i++) {
const _data = await this.set(context, data[i]);
await targetService.addLocal(context, _data);
}
}
}
}
...@@ -3,6 +3,8 @@ import { EntityBaseService, IContext, HttpResponse } from 'ibiz-core'; ...@@ -3,6 +3,8 @@ import { EntityBaseService, IContext, HttpResponse } from 'ibiz-core';
import { GlobalService } from '../global.service'; import { GlobalService } from '../global.service';
import { IRawMaterial, RawMaterial } from '../../entities'; import { IRawMaterial, RawMaterial } from '../../entities';
import keys from '../../entities/raw-material/raw-material-keys'; import keys from '../../entities/raw-material/raw-material-keys';
import { RawMaterialDTOHelp } from '../../entities/raw-material/raw-material-dto-help';
/** /**
* 原材料服务对象基类 * 原材料服务对象基类
......
...@@ -3,7 +3,7 @@ services: ...@@ -3,7 +3,7 @@ services:
trainsys-app-web: trainsys-app-web:
image: dstimage image: dstimage
ports: ports:
- "80:80" - "50100:80"
networks: networks:
- agent_network - agent_network
deploy: deploy:
......
...@@ -16,4 +16,4 @@ CMD echo "The application will start in ${IBIZ_SLEEP}s..." && \ ...@@ -16,4 +16,4 @@ CMD echo "The application will start in ${IBIZ_SLEEP}s..." && \
sleep ${IBIZ_SLEEP} && \ sleep ${IBIZ_SLEEP} && \
yarn start:prod yarn start:prod
EXPOSE 8080 EXPOSE 50100
\ No newline at end of file \ No newline at end of file
...@@ -3,9 +3,16 @@ services: ...@@ -3,9 +3,16 @@ services:
trainsys-app-web: trainsys-app-web:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-app-web:latest image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-app-web:latest
ports: ports:
- "8080:8080" - "50100:50100"
networks: networks:
- agent_network - agent_network
environment:
- NACOS_DISCOVERY_IP=172.16.240.140
- APPLICATION_PORT=50100
- NACOS_SERVER_ADDR=127.0.0.1:8848
- REDIS_HOST=127.0.0.1
- REDIS_PORT=6379
- SPRING_REDIS_DATABASE=0
deploy: deploy:
resources: resources:
limits: limits:
......
...@@ -55,12 +55,34 @@ ...@@ -55,12 +55,34 @@
git clone -b master $para2 trainsys/ git clone -b master $para2 trainsys/
export NODE_OPTIONS=--max-old-space-size=4096 export NODE_OPTIONS=--max-old-space-size=4096
cd trainsys/ cd trainsys/
mvn clean package -Ptrainsys mkdir -p /var/lib/jenkins/appcache/A3064A91-F42D-4D7F-BC1C-4173A4F5772C
mvn install -Ptrainsys if [ -e app_Web/.dynamic ]
cd trainsys-provider then
mvn -Ptrainsys docker:build cd app_Web
mvn -Ptrainsys docker:push else
docker -H $para1 stack deploy --compose-file=src/main/docker/trainsys-provider-trainsys.yaml ebsx --with-registry-auth cd app_Web/app
fi
sed -i "s#dstimage#$para5#g" swarm.yaml
if [[ $para3 = all ]];then
mv Dockerfile-ALL Dockerfile
sed -i "s#/api#/trainsys__web#g" src/environments/environment.ts
sed -i "s#outputDir#//outputDir#g" vue.config.js
yarn
ln -s /var/lib/jenkins/appcache/A3064A91-F42D-4D7F-BC1C-4173A4F5772C node_modules/.cache
yarn build
else
if [ -e .dynamic ]
then
mv ../trainsys-core/src/main/resources/model/cn/ibizlab/trainsys/PSSYSAPPS/Web model
else
mv ../../trainsys-core/src/main/resources/model/cn/ibizlab/trainsys/PSSYSAPPS/Web model
fi
sed -i "s#srcimagename#$para4#g" Dockerfile-MODEL
mv Dockerfile-MODEL Dockerfile
fi
docker build -t $para5 .
docker push $para5
docker -H $para1 stack deploy --compose-file=swarm.yaml ebsx --with-registry-auth
</command> </command>
</hudson.tasks.Shell> </hudson.tasks.Shell>
</builders> </builders>
......
<?xml version="1.1" encoding="UTF-8" standalone="no"?> <?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<!--输出实体[RAWMATERIAL]数据结构 -->
<changeSet author="root" id="tab-rawmaterial-9-1">
<createTable tableName="T_RAWMATERIAL">
<column name="RAWMATERIALID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_RAWMATERIAL"/>
</column>
<column name="CREATEDATE" remarks="" type="DATETIME">
</column>
<column name="RAWMATERIALNAME" remarks="" type="VARCHAR(200)">
</column>
<column name="CREATEMAN" remarks="" type="VARCHAR(60)">
</column>
<column name="UPDATEDATE" remarks="" type="DATETIME">
</column>
<column name="UPDATEMAN" remarks="" type="VARCHAR(60)">
</column>
</createTable>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
...@@ -174,6 +174,14 @@ ...@@ -174,6 +174,14 @@
}, },
"builtinAction" : true "builtinAction" : true
} ], } ],
"getAllPSDEDBConfigs" : [ {
"dBType" : "MYSQL5",
"name" : "MYSQL5",
"objNameCase" : "DEFAULT",
"standardTableName" : "`T_RAWMATERIAL`",
"tableName" : "T_RAWMATERIAL",
"valid" : true
} ],
"getAllPSDEDBTables" : [ { "getAllPSDEDBTables" : [ {
"getAllPSDEFields" : [ { "getAllPSDEFields" : [ {
"name" : "RAWMATERIALID", "name" : "RAWMATERIALID",
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<profiles> <profiles>
<profile> <profile>
<id>trainsys</id> <id>runtime</id>
<build> <build>
<resources> <resources>
<resource> <resource>
......
...@@ -10,6 +10,6 @@ CMD echo "The application will start in ${IBIZ_SLEEP}s..." && \ ...@@ -10,6 +10,6 @@ CMD echo "The application will start in ${IBIZ_SLEEP}s..." && \
sleep ${IBIZ_SLEEP} && \ sleep ${IBIZ_SLEEP} && \
java ${JAVA_OPTS} -Duser.timezone=$TZ -Djava.security.egd=file:/dev/./urandom -jar /trainsys-provider.jar java ${JAVA_OPTS} -Duser.timezone=$TZ -Djava.security.egd=file:/dev/./urandom -jar /trainsys-provider.jar
EXPOSE 50000 EXPOSE 8081
ADD trainsys-provider.jar /trainsys-provider.jar ADD trainsys-provider.jar /trainsys-provider.jar
...@@ -22,30 +22,7 @@ spec: ...@@ -22,30 +22,7 @@ spec:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-provider:latest image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-provider:latest
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 50000 - containerPort: 8081
env:
- name: SPRING_CLOUD_NACOS_DISCOVERY_IP
value: "172.16.240.140"
- name: SERVER_PORT
value: "50000"
- name: SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR
value: "127.0.0.1:8848"
- name: SPRING_REDIS_HOST
value: "127.0.0.1"
- name: SPRING_REDIS_PORT
value: "6379"
- name: SPRING_REDIS_DATABASE
value: "0"
- name: SPRING_DATASOURCE_USERNAME
value: "a_LAB01_d23cc850e"
- name: SPRING_DATASOURCE_PASSWORD
value: "f9Df4556"
- name: SPRING_DATASOURCE_URL
value: "jdbc:mysql://172.16.186.185:3306/a_LAB01_d23cc850e?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&serverTimezone=Asia/Shanghai&allowMultiQueries=true&serverTimezone=GMT%2B8"
- name: SPRING_DATASOURCE_DRIVER-CLASS-NAME
value: "com.mysql.jdbc.Driver"
- name: SPRING_DATASOURCE_DEFAULTSCHEMA
value: "a_LAB01_d23cc850e"
--- ---
apiVersion: v1 apiVersion: v1
...@@ -58,9 +35,9 @@ spec: ...@@ -58,9 +35,9 @@ spec:
type: NodePort type: NodePort
ports: ports:
- name: http - name: http
port: 50000 port: 8081
targetPort: 50000 targetPort: 8081
nodePort: 50000 nodePort: 8081
protocol: TCP protocol: TCP
selector: selector:
app: trainsys-provider app: trainsys-provider
......
...@@ -3,22 +3,9 @@ services: ...@@ -3,22 +3,9 @@ services:
trainsys-provider: trainsys-provider:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-provider:latest image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-provider:latest
ports: ports:
- "50000:50000" - "8081:8081"
networks: networks:
- agent_network - agent_network
environment:
- SPRING_CLOUD_NACOS_DISCOVERY_IP=172.16.240.140
- SERVER_PORT=50000
- SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR=127.0.0.1:8848
- SPRING_CLOUD_NACOS_CONFIG_SERVER-ADDR=127.0.0.1:8848
- SPRING_REDIS_HOST=127.0.0.1
- SPRING_REDIS_PORT=6379
- SPRING_REDIS_DATABASE=0
- SPRING_DATASOURCE_USERNAME=a_LAB01_d23cc850e
- SPRING_DATASOURCE_PASSWORD=f9Df4556
- SPRING_DATASOURCE_URL=jdbc:mysql://172.16.186.185:3306/a_LAB01_d23cc850e?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&serverTimezone=Asia/Shanghai&allowMultiQueries=true&serverTimezone=GMT%2B8
- SPRING_DATASOURCE_DRIVER-CLASS-NAME=com.mysql.jdbc.Driver
- SPRING_DATASOURCE_DEFAULTSCHEMA=a_LAB01_d23cc850e
deploy: deploy:
resources: resources:
limits: limits:
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册