cellsysArt/artSystem.js
yangrd 042db644d9 1,增加LIA联合查询修复档案接口
2,修复档案增加遗漏的发布字段及组织名称
3,删除ArtSystem的orgId,增加unionStatus,并在查询修复档案列表增加联合查询
4,@airkoon/cellsys的地址更改
2025-03-31 10:20:37 +08:00

780 lines
27 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Query, QueryTask } from './artUtil.js';
import { QueryType } from '@airkoon/cellsys/cellsysUtil.js';
import ConditionReport from './conditionReport';
import { artApi } from './artApi';
import CellsysArt from './cellsysArt';
import CellsysEventType from '@airkoon/cellsys/cellsysEventType';
import ArtCounty from './artCounty';
import { EditTask } from './artUtil.js';
import ArtRepairFile from './artRepairFile';
import ArtRepairPlan from './artRepairPlan';
import * as http from './utils/axios';
import ArtRepairLog from './artRepairLog';
import MaterialType from './materialType';
import materialType from './materialType';
import Material from './material';
import ArtCategory from './artCategory';
import Equipment from './equipment';
import Laboratory from './laboratory';
import ArtworkEquipmentType from './equipmentType';
import EquipmentData from './equipmentData';
class ArtSystem {
constructor(orgId) {
}
static unionStatus=null
static token = null;
//查询艺术品材质字典
//static queryMaterials(params = {}) {
static queryTexture(params = {}) {
let query = new Query();
let { filter } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
query.addFilter('dict_type', '=', 'material');
let queryTask = new QueryTask(QueryType.sysDictData, false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
}
//查询艺术品一级分类
static queryArtCategoryOne(params = {}) {
let query = new Query();
let { filter, pageInfo } = params;
if (pageInfo) {
query.setCurrPage(pageInfo.currPage);
query.setPageSize(pageInfo.pageSize);
}
query.addFilter('parent_id', '=', 1);
query.setOrder({ sort: 'asc' });
let queryTask = new QueryTask(QueryType.sysCategoryData, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new ArtCategory(item);
});
resolve(res);
} else {
reject(new Error('艺术品类别数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new ArtCategory(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//根据父级id查询分类
static queryArtCategoryById(parentId) {
let query = new Query();
query.addFilter('parent_id', '=', parentId);
query.setOrder({ sort: 'asc' });
let queryTask = new QueryTask(QueryType.sysCategoryData, false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
let resArr = res.map((item) => {
return new ArtCategory(item);
});
resolve(resArr);
})
.catch((err) => {
reject(err);
});
});
}
//创建分类字典
static createArtCategory(params = {}) {
let { parentId, code, name, sort, description } = params;
let editTask = new EditTask(artApi.cellsysSysDictCategoryInsert);
editTask.addParam('_parent_id', parentId ? parentId : 1); //这里分类字典的parentId固定是1为艺术品类别
editTask.addParam('_code', code);
editTask.addParam('_name', name);
editTask.addParam('_sort', sort);
editTask.addParam('_description', description);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let artRepairFile = new ArtCategory(res.data);
resolve(artRepairFile);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询国家数据
static queryCountry(params = {}) {
let query = new Query();
let { pageInfo, order, filter } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
let queryTask = new QueryTask(artApi.country, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new ArtCounty(item);
});
resolve(res);
}
} else {
let resArr = res.map((item) => {
return new ArtCounty(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询艺术片档案
static queryArtworks(params = {}) {
let query = new Query();
let { pageInfo, order, filter } = params;
if (pageInfo) {
query.setCurrPage(pageInfo.currPage);
query.setPageSize(pageInfo.pageSize);
}
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
} else {
query.setOrder({ id: 'desc' });
}
let queryTask = new QueryTask(artApi.artworkRecord, pageInfo ? true : false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new CellsysArt(item);
});
resolve(res);
}
} else {
let resArr = res.map((item) => {
return new CellsysArt(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//创建艺术品档案
static createArtwork(params = {}) {
let editTask = new EditTask(artApi.artArtworkRecordInsert);
editTask.addParam('_oldname', params.oldName);
editTask.addParam('_countryId', params.country.id);
editTask.addParam('_countryCode', params.country.code);
editTask.addParam('_author', params.author);
editTask.addParam('_create_period', params.createPeriod);
editTask.addParam('_actual_number', params.actualNumber);
if (params.texture) {
editTask.addParam('_texture', params.texture.dict_code);
}
if (params.categoryOne) {
editTask.addParam('_category_one', params.categoryOne.id);
editTask.addParam('_category_one_code', params.categoryOne.code);
}
if (params.categoryTwo) {
editTask.addParam('_category_two', params.categoryTwo.id);
editTask.addParam('_category_two_code', params.categoryTwo.code);
}
if (params.categoryThree) {
editTask.addParam('_category_three', params.categoryThree.id);
}
editTask.addParam('_original_registration_number', params.originalRegistrationNumber);
editTask.addParam('_remark', params.remarks);
editTask.addParam('_images', params.images);
if (params.size && params.size.length > 0) {
editTask.addParam(
'_size',
params.size.map((item) => {
return item.toParams();
}),
);
}
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let cellsysArt = new CellsysArt(res.data);
resolve(cellsysArt);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询报告列表(应用列表)
static queryConditionsReports(params) {
if (!params) {
params = {};
}
let query = new Query();
let pageInfo = params.pageInfo;
let order = params.order;
if (pageInfo) {
query.setCurrPage(pageInfo.currPage);
query.setPageSize(pageInfo.pageSize);
}
if (order) {
query.setOrder(order);
} else {
query.setOrder({ id: 'desc' });
}
// query.addFilter('model_id', "=", 23); //病害报告模板
let filter = params.filter;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']); //病害报告模板
});
}
let queryTask = new QueryTask(artApi.viewConditionCheck, pageInfo ? true : false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new ConditionReport(item);
});
resolve(res);
}
} else {
let resArr = res.map((item) => {
return new ConditionReport(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
static queryArtworkByRepairId(params) {
let query = new Query();
let artworkId = params.artworkId;
let eventSetId = params.eventSetId;
if (artworkId) {
query.addFilter('artwork.id', '=', artworkId); //病害报告模板
}
if (eventSetId) {
query.addFilter('event_set.id', '=', eventSetId); //病害报告模板
}
let queryTask = new QueryTask(artApi.artworkRepair, false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
let resArr = res.map((item) => {
return new CellsysArt(item.artwork);
});
resolve(resArr);
})
.catch((err) => {
reject(err);
});
});
}
static queryArtworkEvent(params) {
let query = new Query();
let artworkId = params.artworkId;
if (artworkId) {
query.addFilter('artwork.id', '=', artworkId); //病害报告模板
}
let queryTask = new QueryTask(artApi.artworkRepair, false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
let resArr = res.map((item) => {
return new CellsysEventType(item.event_set);
});
resolve(resArr);
})
.catch((err) => {
reject(err);
});
});
}
//查询系统修复档案列表
static queryRepairFiles(params) {
let query = new Query();
let { filter, pageInfo,getUnion } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
let queryType=artApi.viewRepairRecord
if ( ArtSystem.unionStatus&&getUnion === true) {
//联合状态为父级组织,并且需要获取联合信息
queryType = artApi.viewOrgUnionRepairRecord;
} else {
query.setOrder({ org_id: 'asc', id: 'desc' });
}
let queryTask = new QueryTask(queryType, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new ArtRepairFile(item);
});
resolve(res);
} else {
reject(new Error('修复档案数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new ArtRepairFile(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询系统修复方案列表
static queryRepairPlan(params) {
let query = new Query();
let { filter, pageInfo } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
let queryTask = new QueryTask(artApi.viewRepairPlan, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new ArtRepairPlan(item);
});
resolve(res);
} else {
reject(new Error('修复方案数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new ArtRepairPlan(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询系统修复记录列表
static queryRepairLogs(params) {
let query = new Query();
let { filter, pageInfo, order } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
}
let queryTask = new QueryTask(artApi.viewRepairLog, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new ArtRepairLog(item);
});
resolve(res);
} else {
reject(new Error('修复记录数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new ArtRepairLog(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询材料类型列表
static queryMaterialType(params) {
let query = new Query();
let { filter, pageInfo, order } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
}
let queryTask = new QueryTask(artApi.viewMaterialType, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new MaterialType(item);
});
resolve(res);
} else {
reject(new Error('数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new MaterialType(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//创建材料类型
static createMaterialType(params) {
let editTask = new EditTask(artApi.materialTypeInsert);
editTask.addParam('_name', params.name);
editTask.addParam('_description', params.description);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let materialType = new MaterialType(res.data);
resolve(materialType);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询材料列表
static queryMaterial(params) {
let query = new Query();
let { filter, pageInfo, order } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
}
let queryTask = new QueryTask(artApi.viewMaterial, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new Material(item);
});
resolve(res);
} else {
reject(new Error('数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new Material(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询设备类型列表
static queryEquipmentType(params) {
let query = new Query();
let { filter, pageInfo, order } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
}
let queryTask = new QueryTask(artApi.viewEquipmentType, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new ArtworkEquipmentType(item);
});
resolve(res);
} else {
reject(new Error('数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new ArtworkEquipmentType(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//创建设备类型
static createEquipmentType(params) {
let editTask = new EditTask(artApi.equipmentTypeInsert);
editTask.addParam('_name', params.name);
editTask.addParam('_data_type', params.dataType);
editTask.addParam('_style', params.style);
editTask.addParam('_chart_option', params.chartConfiguration);
editTask.addParam('_description', params.description);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let materialType = new ArtworkEquipmentType(res.data);
resolve(materialType);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询设备列表
static queryEquipment(params = {}) {
let query = new Query();
let { filter, pageInfo, order } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
}
let queryTask = new QueryTask(artApi.viewEquipment, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new Equipment(item);
});
resolve(res);
} else {
reject(new Error('数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new Equipment(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询设备数据
static viewArtworkEquipmentData(params) {
let query = new Query();
let { filter, pageInfo, order } = params;
// query.addFilter('equipment_id', '=', this.id);
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
}
let queryTask = new QueryTask(artApi.viewArtworkEquipmentData, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new EquipmentData(item);
});
resolve(res);
} else {
reject(new Error('数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new EquipmentData(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//查询实验室列表
static queryLaboratoryList(params) {
let query = new Query();
let { filter, pageInfo, order } = params;
if (filter) {
filter.forEach((item) => {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
if (order) {
query.setOrder(order);
}
let queryTask = new QueryTask(artApi.viewLaboratory, !!pageInfo);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
.then((res) => {
if (pageInfo) {
if (res.data) {
res.data = res.data.map((item) => {
return new Laboratory(item);
});
resolve(res);
} else {
reject(new Error('数据格式异常'));
}
} else {
let resArr = res.map((item) => {
return new Laboratory(item);
});
resolve(resArr);
}
})
.catch((err) => {
reject(err);
});
});
}
//创建实验室
static createLaboratory(params) {
let editTask = new EditTask(artApi.laboratoryInsert);
editTask.addParam('_name', params.name);
editTask.addParam('_geometry', params.geometry);
editTask.addParam('_geometry_position', params.geometryPosition);
editTask.addParam('_description', params.description);
return new Promise((resolve, reject) => {
editTask
.execute()
.then((res) => {
if (res.data) {
let materialType = new Laboratory(res.data);
resolve(materialType);
}
})
.catch((err) => {
reject(err);
});
});
}
//统一图片上传
static uploadImage(params = {}) {
let { files, module } = params;
let fd = new FormData();
fd.append('file', files);
fd.append('module', module);
return http.post(`/v2${artApi.artUploadPicture}`, fd, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
}
export default ArtSystem;