数据定价对接计算接口
Showing
3 changed files
with
155 additions
and
105 deletions
| ... | @@ -242,6 +242,15 @@ export const getPriceResult = (params) => { | ... | @@ -242,6 +242,15 @@ export const getPriceResult = (params) => { |
| 242 | }); | 242 | }); |
| 243 | }; | 243 | }; |
| 244 | 244 | ||
| 245 | // 计算数据定价 | ||
| 246 | export const calculatPrice = (params) => { | ||
| 247 | return request({ | ||
| 248 | url: `${import.meta.env.VITE_API_NEW_PORTAL}/pricing-data/calculate-price`, | ||
| 249 | method: "post", | ||
| 250 | data: params, | ||
| 251 | }); | ||
| 252 | }; | ||
| 253 | |||
| 245 | // 删除数据定价 | 254 | // 删除数据定价 |
| 246 | export const deletePrice = (params) => { | 255 | export const deletePrice = (params) => { |
| 247 | return request({ | 256 | return request({ | ... | ... |
| ... | @@ -21,7 +21,8 @@ import { | ... | @@ -21,7 +21,8 @@ import { |
| 21 | savePrice, | 21 | savePrice, |
| 22 | getModelDemand, | 22 | getModelDemand, |
| 23 | getPriceResult, | 23 | getPriceResult, |
| 24 | exportModelScore | 24 | exportModelScore, |
| 25 | calculatPrice | ||
| 25 | } from '@/api/modules/dataPricing'; | 26 | } from '@/api/modules/dataPricing'; |
| 26 | import { changeNum } from "@/utils/common"; | 27 | import { changeNum } from "@/utils/common"; |
| 27 | 28 | ||
| ... | @@ -908,72 +909,159 @@ const calculatePrice = (pData) => { | ... | @@ -908,72 +909,159 @@ const calculatePrice = (pData) => { |
| 908 | } | 909 | } |
| 909 | }; | 910 | }; |
| 910 | 911 | ||
| 912 | // 获取定价计算配置参数 | ||
| 913 | const getCalculateParams = (baseConfigFormObj, baseConfigFormInfo) => { | ||
| 914 | const modelName = typeMap.value.modelGuid.find(d => d.guid == baseConfigFormInfo.modelGuid)?.modelName || ''; | ||
| 915 | const dataResourceName = typeMap.value.dataResourceGuid.find(d => d.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; | ||
| 916 | const diseaseGuid = baseConfigFormInfo.diseaseGuid || ''; | ||
| 917 | let params: any = { | ||
| 918 | tenantGuid: userData.tenantGuid, | ||
| 919 | dataTransactionPrice: dataTransactionPrice.value, | ||
| 920 | modelGuid: baseConfigFormInfo.modelGuid, | ||
| 921 | modelName, | ||
| 922 | dataResourceGuid: baseConfigFormInfo.dataResourceGuid, | ||
| 923 | dataResourceName, | ||
| 924 | belongingEntityGuid: baseConfigFormInfo.belongingEntityGuid, | ||
| 925 | belongingTheme: baseConfigFormInfo.belongingTheme, | ||
| 926 | diseaseGuid, | ||
| 927 | diseaseName: '', | ||
| 928 | dataUsage: dataUsage.value | ||
| 929 | }; | ||
| 930 | if (diseaseGuid) { | ||
| 931 | const parentsData = baseConfigFormObj.getCascaderCheckedData(); | ||
| 932 | params.diseaseName = parentsData[0]?.label || ''; | ||
| 933 | } | ||
| 934 | let dictionaryJson = {}; | ||
| 935 | for (var b in baseConfigFormInfo) { | ||
| 936 | if (b.indexOf('dict_') > -1) { | ||
| 937 | dictionaryJson[b] = baseConfigFormInfo[b]; | ||
| 938 | } | ||
| 939 | } | ||
| 940 | params.dictionaryJson = Object.keys(dictionaryJson).length ? JSON.stringify(dictionaryJson) : ''; | ||
| 941 | let demandMatchingData: any = []; | ||
| 942 | tableData.value.map(item => { | ||
| 943 | demandMatchingData.push({ | ||
| 944 | demandTableName: item.demandTableName, | ||
| 945 | demandTableGuid: item.demandTableGuid || item.guid, // 需求表guid | ||
| 946 | dataTableGuid: item.dataTableGuid || '', // 数据资源表guid | ||
| 947 | weightDemandTable: item.weightDemandTable, | ||
| 948 | dataFieldsNum: item.dataFieldsNum, | ||
| 949 | pricingDemandFieldRQVOS: item.dataFields.map(d => { | ||
| 950 | return { | ||
| 951 | demandFieldGuid: d.demandFieldGuid || d.guid, // 资源表字段guid | ||
| 952 | fieldName: d.fieldName, | ||
| 953 | enName: d.enName, | ||
| 954 | chName: d.chName, | ||
| 955 | isRequired: d.isRequired, | ||
| 956 | orderNum: d.orderNum | ||
| 957 | } | ||
| 958 | }) | ||
| 959 | }) | ||
| 960 | }); | ||
| 961 | params.dataPricingDemandmatchingRQVOS = demandMatchingData; | ||
| 962 | guid && (params.guid = guid); | ||
| 963 | return params; | ||
| 964 | } | ||
| 965 | |||
| 966 | // 获取定价计算结构 | ||
| 967 | const getCalculatPrice = async (params) => { | ||
| 968 | try { | ||
| 969 | const res: any = await calculatPrice(params); | ||
| 970 | loading.value = false; | ||
| 971 | if (res.code === proxy.$passCode) { | ||
| 972 | const data = res.data || {}; | ||
| 973 | console.log('getCalculatPrice', data); | ||
| 974 | return data; // 返回计算结果以便后续使用 | ||
| 975 | } else { | ||
| 976 | proxy.$ElMessage.error(res.msg); | ||
| 977 | throw new Error(res.msg); // 抛出错误以便 catch 捕获 | ||
| 978 | } | ||
| 979 | } catch (error) { | ||
| 980 | console.error('计算价格失败:', error); | ||
| 981 | loading.value = false; | ||
| 982 | throw error; // 重新抛出错误 | ||
| 983 | } | ||
| 984 | }; | ||
| 985 | |||
| 911 | // 计算结果和提交 | 986 | // 计算结果和提交 |
| 912 | const checkForm = (type) => { | 987 | const checkForm = (type) => { |
| 913 | const baseConfigFormObj = baseConfigFormRef.value; | 988 | const baseConfigFormObj = baseConfigFormRef.value; |
| 914 | const baseConfigFormEl = baseConfigFormObj.ruleFormRef; | 989 | const baseConfigFormEl = baseConfigFormObj.ruleFormRef; |
| 915 | const baseConfigFormInfo = baseConfigFormObj.formInline; | 990 | const baseConfigFormInfo = baseConfigFormObj.formInline; |
| 916 | baseConfigFormEl.validate((valid, errorItem) => { | 991 | baseConfigFormEl.validate(async (valid, errorItem) => { |
| 917 | if (valid) { | 992 | if (valid) { |
| 993 | const params = getCalculateParams(baseConfigFormObj, baseConfigFormInfo); | ||
| 994 | loading.value = true; | ||
| 995 | // 先获取计算结果 | ||
| 996 | const priceData = await getCalculatPrice(params); | ||
| 997 | // 显示结果 | ||
| 998 | dataTransactionPrice.value = priceData.transactionPrice; | ||
| 999 | |||
| 918 | if (type == 'calculate') { | 1000 | if (type == 'calculate') { |
| 919 | const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | 1001 | // const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); |
| 920 | exportData.value = resultInfo; | 1002 | // exportData.value = resultInfo; |
| 921 | calculatePrice(signatoryData); | 1003 | // calculatePrice(signatoryData); |
| 922 | } else if (type == 'export') { | 1004 | } else if (type == 'export') { |
| 923 | const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | 1005 | // const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); |
| 924 | exportData.value = resultInfo; | 1006 | // exportData.value = resultInfo; |
| 925 | !dataTransactionPrice.value && calculatePrice(signatoryData); | 1007 | // !dataTransactionPrice.value && calculatePrice(signatoryData); |
| 926 | loading.value = true; | 1008 | // loading.value = true; |
| 927 | let exportOut: any = {}; | 1009 | // let exportOut: any = {}; |
| 928 | // 估值对象信息 | 1010 | // // 估值对象信息 |
| 929 | const damName = typeMap.value.dataResourceGuid.find(f => f.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; | 1011 | // const damName = typeMap.value.dataResourceGuid.find(f => f.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; |
| 930 | exportOut.one = `因${baseConfigFormInfo.belongingEntityGuid}拟了解其所持有的\"${damName}\"相关数据资源的价格,为此需对该行为涉及的数据资源在不同应用场景下,基于数据资源持有单位的性质、信息化程度、数据稀缺性、需求匹配等情况下,为上述经济行为提供定价参考依据。`; | 1012 | // exportOut.one = `因${baseConfigFormInfo.belongingEntityGuid}拟了解其所持有的\"${damName}\"相关数据资源的价格,为此需对该行为涉及的数据资源在不同应用场景下,基于数据资源持有单位的性质、信息化程度、数据稀缺性、需求匹配等情况下,为上述经济行为提供定价参考依据。`; |
| 931 | exportOut.two = `估值对象:${baseConfigFormInfo.belongingEntityGuid}持有的\"${damName}\"`; | 1013 | // exportOut.two = `估值对象:${baseConfigFormInfo.belongingEntityGuid}持有的\"${damName}\"`; |
| 932 | // 估值范围信息 | 1014 | // // 估值范围信息 |
| 933 | const damNames = demandTableList.value.map(item => item.menuName) | 1015 | // const damNames = demandTableList.value.map(item => item.menuName) |
| 934 | let rangStr = `包含${damNames.join('、')}等${damNames.length}张表单,${damNames.length}张表共计${demandTableFieldAllNum.value}个字段`; | 1016 | // let rangStr = `包含${damNames.join('、')}等${damNames.length}张表单,${damNames.length}张表共计${demandTableFieldAllNum.value}个字段`; |
| 935 | const dataTimeliness = pricingTargetList.value.find(p => p.dictionaryName == '时效性'); | 1017 | // const dataTimeliness = pricingTargetList.value.find(p => p.dictionaryName == '时效性'); |
| 936 | const dataTimelinessStr = dataTimeliness ? typeMap.value[`dict_${dataTimeliness.guid}`].find(f => f.value == baseConfigFormInfo[`dict_${dataTimeliness.guid}`])?.label || '' : ''; | 1018 | // const dataTimelinessStr = dataTimeliness ? typeMap.value[`dict_${dataTimeliness.guid}`].find(f => f.value == baseConfigFormInfo[`dict_${dataTimeliness.guid}`])?.label || '' : ''; |
| 937 | rangStr += dataTimelinessStr ? `,时间跨度为${dataTimelinessStr}的数据` : `的数据`; | 1019 | // rangStr += dataTimelinessStr ? `,时间跨度为${dataTimelinessStr}的数据` : `的数据`; |
| 938 | damNames.length && (exportOut.two = `${exportOut.two}\n估值范围:${rangStr}`); | 1020 | // damNames.length && (exportOut.two = `${exportOut.two}\n估值范围:${rangStr}`); |
| 939 | // 字典 | 1021 | // // 字典 |
| 940 | let dictList: any = [], hasModelScore = false; | 1022 | // let dictList: any = [], hasModelScore = false; |
| 941 | const dictStr = exportData.value.map(e => { | 1023 | // const dictStr = exportData.value.map(e => { |
| 942 | // 检查是否有质量模型评分 | 1024 | // // 检查是否有质量模型评分 |
| 943 | hasModelScore = hasModelScore || e.pricingTargetRSVOS.some( | 1025 | // hasModelScore = hasModelScore || e.pricingTargetRSVOS.some( |
| 944 | t => t.targetType === '2' && t.functionName === '1' | 1026 | // t => t.targetType === '2' && t.functionName === '1' |
| 945 | ); | 1027 | // ); |
| 946 | 1028 | ||
| 947 | // 只有当维度指标数大于1时才处理明细 | 1029 | // // 只有当维度指标数大于1时才处理明细 |
| 948 | if (e.pricingTargetRSVOS.length > 1) { | 1030 | // if (e.pricingTargetRSVOS.length > 1) { |
| 949 | const targetStr = e.pricingTargetRSVOS | 1031 | // const targetStr = e.pricingTargetRSVOS |
| 950 | .map(t => `${t.targetName}为${changeNum(t.tNum, 2)}`) | 1032 | // .map(t => `${t.targetName}为${changeNum(t.tNum, 2)}`) |
| 951 | .join('、'); | 1033 | // .join('、'); |
| 952 | 1034 | ||
| 953 | dictList.push(`${e.dimensionalityName}为${changeNum(e.sNum, 2)},其中${targetStr}`); | 1035 | // dictList.push(`${e.dimensionalityName}为${changeNum(e.sNum, 2)},其中${targetStr}`); |
| 954 | } | 1036 | // } |
| 955 | 1037 | ||
| 956 | return `${e.dimensionalityName}为${changeNum(e.sNum, 2)}`; | 1038 | // return `${e.dimensionalityName}为${changeNum(e.sNum, 2)}`; |
| 957 | }) | 1039 | // }) |
| 958 | let dictListStr = `${dictStr.join(',')}。\n${dictList.join(';\n')}` | 1040 | // let dictListStr = `${dictStr.join(',')}。\n${dictList.join(';\n')}` |
| 959 | // 质量模型 | 1041 | // // 质量模型 |
| 960 | if (hasModelScore) { | 1042 | // if (hasModelScore) { |
| 961 | const { largeCategoryScoreList = [], qualityScore = 0 } = qualityScoreData.value; | 1043 | // const { largeCategoryScoreList = [], qualityScore = 0 } = qualityScoreData.value; |
| 962 | const qualityParts = [ | 1044 | // const qualityParts = [ |
| 963 | `数据的总体质量得分为${changeNum(qualityScore, 2)}` | 1045 | // `数据的总体质量得分为${changeNum(qualityScore, 2)}` |
| 964 | ]; | 1046 | // ]; |
| 965 | 1047 | ||
| 966 | if (largeCategoryScoreList.length) { | 1048 | // if (largeCategoryScoreList.length) { |
| 967 | const categoryScores = largeCategoryScoreList.map( | 1049 | // const categoryScores = largeCategoryScoreList.map( |
| 968 | q => `${q.largeCategoryName}方面得分为${changeNum(q.largeCategoryScore || 0, 2)}` | 1050 | // q => `${q.largeCategoryName}方面得分为${changeNum(q.largeCategoryScore || 0, 2)}` |
| 969 | ); | 1051 | // ); |
| 970 | qualityParts.push(`其中${categoryScores.join(',')}`); | 1052 | // qualityParts.push(`其中${categoryScores.join(',')}`); |
| 971 | } | 1053 | // } |
| 972 | 1054 | ||
| 973 | dictListStr += `;\n${qualityParts.join('。')}`; | 1055 | // dictListStr += `;\n${qualityParts.join('。')}`; |
| 974 | } | 1056 | // } |
| 975 | exportOut.three = `${baseConfigFormInfo.belongingEntityGuid}持有的"${damName}"的数据(患者人次)单价为${changeNum(dataTransactionPrice.value, 2)}元${dictListStr ? `;其中${dictListStr}` : '。'}`; | 1057 | // exportOut.three = `${baseConfigFormInfo.belongingEntityGuid}持有的"${damName}"的数据(患者人次)单价为${changeNum(dataTransactionPrice.value, 2)}元${dictListStr ? `;其中${dictListStr}` : '。'}`; |
| 976 | 1058 | ||
| 1059 | loading.value = true; | ||
| 1060 | const exportOut = { | ||
| 1061 | one: priceData.one, | ||
| 1062 | two: priceData.two, | ||
| 1063 | three: priceData.three, | ||
| 1064 | } | ||
| 977 | exportModelScore(exportOut).then((res: any) => { | 1065 | exportModelScore(exportOut).then((res: any) => { |
| 978 | loading.value = false; | 1066 | loading.value = false; |
| 979 | if (res && !res.msg) { | 1067 | if (res && !res.msg) { |
| ... | @@ -993,58 +1081,10 @@ const checkForm = (type) => { | ... | @@ -993,58 +1081,10 @@ const checkForm = (type) => { |
| 993 | }); | 1081 | }); |
| 994 | }) | 1082 | }) |
| 995 | } else { | 1083 | } else { |
| 996 | const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | 1084 | // const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); |
| 997 | exportData.value = resultInfo; | 1085 | // exportData.value = resultInfo; |
| 998 | !dataTransactionPrice.value && calculatePrice(signatoryData); | 1086 | // !dataTransactionPrice.value && calculatePrice(signatoryData); |
| 999 | const modelName = typeMap.value.modelGuid.find(d => d.guid == baseConfigFormInfo.modelGuid)?.modelName || ''; | 1087 | |
| 1000 | const dataResourceName = typeMap.value.dataResourceGuid.find(d => d.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; | ||
| 1001 | const diseaseGuid = baseConfigFormInfo.diseaseGuid || ''; | ||
| 1002 | let params: any = { | ||
| 1003 | tenantGuid: userData.tenantGuid, | ||
| 1004 | dataTransactionPrice: dataTransactionPrice.value, | ||
| 1005 | modelGuid: baseConfigFormInfo.modelGuid, | ||
| 1006 | modelName, | ||
| 1007 | dataResourceGuid: baseConfigFormInfo.dataResourceGuid, | ||
| 1008 | dataResourceName, | ||
| 1009 | belongingEntityGuid: baseConfigFormInfo.belongingEntityGuid, | ||
| 1010 | belongingTheme: baseConfigFormInfo.belongingTheme, | ||
| 1011 | diseaseGuid, | ||
| 1012 | diseaseName: '', | ||
| 1013 | dataUsage: dataUsage.value | ||
| 1014 | }; | ||
| 1015 | if (diseaseGuid) { | ||
| 1016 | const parentsData = baseConfigFormObj.getCascaderCheckedData(); | ||
| 1017 | params.diseaseName = parentsData[0]?.label || ''; | ||
| 1018 | } | ||
| 1019 | let dictionaryJson = {}; | ||
| 1020 | for (var b in baseConfigFormInfo) { | ||
| 1021 | if (b.indexOf('dict_') > -1) { | ||
| 1022 | dictionaryJson[b] = baseConfigFormInfo[b]; | ||
| 1023 | } | ||
| 1024 | } | ||
| 1025 | params.dictionaryJson = Object.keys(dictionaryJson).length ? JSON.stringify(dictionaryJson) : ''; | ||
| 1026 | let demandMatchingData: any = []; | ||
| 1027 | tableData.value.map(item => { | ||
| 1028 | demandMatchingData.push({ | ||
| 1029 | demandTableName: item.demandTableName, | ||
| 1030 | demandTableGuid: item.demandTableGuid || item.guid, // 需求表guid | ||
| 1031 | dataTableGuid: item.dataTableGuid, // 数据资源表guid | ||
| 1032 | weightDemandTable: item.weightDemandTable, | ||
| 1033 | dataFieldsNum: item.dataFieldsNum, | ||
| 1034 | pricingDemandFieldRQVOS: item.dataFields.map(d => { | ||
| 1035 | return { | ||
| 1036 | demandFieldGuid: d.demandFieldGuid || d.guid, // 资源表字段guid | ||
| 1037 | fieldName: d.fieldName, | ||
| 1038 | enName: d.enName, | ||
| 1039 | chName: d.chName, | ||
| 1040 | isRequired: d.isRequired, | ||
| 1041 | orderNum: d.orderNum | ||
| 1042 | } | ||
| 1043 | }) | ||
| 1044 | }) | ||
| 1045 | }); | ||
| 1046 | params.dataPricingDemandmatchingRQVOS = demandMatchingData; | ||
| 1047 | guid && (params.guid = guid); | ||
| 1048 | loading.value = true; | 1088 | loading.value = true; |
| 1049 | savePrice(params).then((res: any) => { | 1089 | savePrice(params).then((res: any) => { |
| 1050 | loading.value = false; | 1090 | loading.value = false; | ... | ... |
| ... | @@ -1095,6 +1095,7 @@ const open = (msg, type, target) => { | ... | @@ -1095,6 +1095,7 @@ const open = (msg, type, target) => { |
| 1095 | } | 1095 | } |
| 1096 | }); | 1096 | }); |
| 1097 | }; | 1097 | }; |
| 1098 | |||
| 1098 | const drawerBtnClick = async (btn, info) => { | 1099 | const drawerBtnClick = async (btn, info) => { |
| 1099 | if (btn.value == "submit") { | 1100 | if (btn.value == "submit") { |
| 1100 | let params = { ...info }; | 1101 | let params = { ...info }; | ... | ... |
-
Please register or sign in to post a comment