Skip to content

Commit

Permalink
fix 自动化服务类传参错误
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Nov 22, 2024
1 parent 797d017 commit 2026ac3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/common/iServer/GeoprocessingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class GeoprocessingService extends CommonServiceBase {
parameter = parameter ? parameter : null;
environment = environment ? environment : null;
const executeParamter = { parameter, environment };
return this._processAsync({ url: `${this.url}/${identifier}/execute`, executeParamter, callback });
return this._processAsync({ url: `${this.url}/${identifier}/execute`, paramter:executeParamter, callback });
}
/**
* @function GeoprocessingService.prototype.submitJob
Expand All @@ -67,7 +67,7 @@ export class GeoprocessingService extends CommonServiceBase {
parameter = parameter ? parameter : null;
environments = environments ? environments : null;
const asyncParamter = JSON.stringify({ parameter: parameter, environments: environments });
return this._processAsync({ url: `${this.url}/${identifier}/jobs`, method: 'POST', callback, params: asyncParamter });
return this._processAsync({ url: `${this.url}/${identifier}/jobs`, method: 'POST', callback, data: asyncParamter });
}

/**
Expand Down Expand Up @@ -152,11 +152,12 @@ export class GeoprocessingService extends CommonServiceBase {
return this._processAsync({ url, callback });
}

_processAsync({ url, method, callback, paramter }) {
_processAsync({ url, method, callback, paramter, data }) {
return this.request({
url: url,
method: method || 'GET',
params: paramter,
data,
headers: { 'Content-type': 'application/json' },
scope: this,
success: callback,
Expand Down
9 changes: 7 additions & 2 deletions test/common/iServer/GeoprocessingServiceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ describe('GeoprocessingService', () => {
};
const executeService = new GeoprocessingService(serverUrl);
expect(executeService).not.toBeNull();
spyOn(FetchRequest, 'get').and.callFake((url) => {
spyOn(FetchRequest, 'get').and.callFake((url, params) => {
expect(params).not.toBeNull();
expect(params.parameter['readasfeaturerdd-dataConnInfo']).toBe('sdx --server=C:/Users/MEVHREVO/Desktop/mode/111.udbx --dbType=udbx --dataset=ccccc_result_R');
const URL = serverUrl + '/sps.WorkflowProcessFactory.models:sps/execute';
expect(url).toBe(URL);
return Promise.resolve(new Response(`{"countrdd-resultCount":"12","succeed":true}`));
Expand Down Expand Up @@ -140,7 +142,10 @@ describe('GeoprocessingService', () => {
};
const submitJobService = new GeoprocessingService(serverUrl);
expect(submitJobService).not.toBeNull();
spyOn(FetchRequest, 'post').and.callFake((url) => {
spyOn(FetchRequest, 'post').and.callFake((url, params) => {
expect(params).not.toBeNull();
var paramsObj = JSON.parse(params.replace(/'/g, '"'));
expect(paramsObj.parameter['readasfeaturerdd-dataConnInfo']).toBe("sdx --server=C:/Users/MEVHREVO/Desktop/mode/111.udbx --dbType=udbx --dataset=ccccc_result_R");
expect(url).toBe(`${serverUrl}/sps.WorkflowProcessFactory.models:sps/jobs`);
return Promise.resolve(
new Response(`{"jobID":"gp-20200916-104559-40E52","status":"started","succeed":true}`)
Expand Down

0 comments on commit 2026ac3

Please sign in to comment.