1117 lines
48 KiB
JavaScript
1117 lines
48 KiB
JavaScript
// JavaScript source code
|
|
|
|
|
|
///////////////////////////////////////////////////
|
|
//该部分是Vue应用封装
|
|
var Gaddress = localStorage.getItem("Gaddress")
|
|
var pubserver = localStorage.getItem("pubserver")
|
|
var mongoApi = localStorage.getItem("mongoApi")
|
|
|
|
var app = new Vue({
|
|
el: '#app',
|
|
data() {
|
|
return {
|
|
//=====================第四步的相关参数开始===================
|
|
fourth_data: [],
|
|
fourth_data_result: [],
|
|
textarea_fourth: "",
|
|
AnalyzeList: [
|
|
{label: '<span style="color: red;">未分析</span>', value: 0},
|
|
{label: '<span style="color: green;">智能修改</span>', value: 2},
|
|
{label: '<span style="color: blue;">智能推荐</span>', value: 3}
|
|
],
|
|
//当前第四步运行分析的位置
|
|
curFourthAnalyzePos: 0,
|
|
curFourthAnalyzePos_Display: 1,
|
|
//是否第四步是暂停状态
|
|
isFourthPause: false,
|
|
//=============第四步的相关参数结束================
|
|
|
|
//向导页目前的第几页
|
|
activeName: 'first',
|
|
//需要处理的年份
|
|
curYear: '',
|
|
//提示内容显示
|
|
textarea: "",
|
|
searchJson: {'ypmc': '', 'sp_dl': '', 'years': []},
|
|
searchYearTempJson: {'ypmc': '', 'sp_dl': ''},
|
|
//等待提示
|
|
loading: false,
|
|
showtip: '',
|
|
btnLoading: [false, false, false, false, false, false, false, false, false, false, false, false],
|
|
//正在进行实时更新替换, 大约需要30秒钟至几分钟不等, 请等待...
|
|
showLoadingTip: '系统正在操作中,请耐心的等待...',
|
|
|
|
|
|
//第一步的下拉菜单
|
|
First_SelYPMC: '',
|
|
First_SelYPMCs: [],
|
|
First_SelDaLei: '',
|
|
First_SelDaLeis: [],
|
|
|
|
Classify_currentPage: 1, //初始页_历史数据库
|
|
Classify_pagesize: 5, //每页的数据_历史数据库
|
|
|
|
YearTemp_currentPage: 1, //初始页_年临时数据库
|
|
YearTemp_pagesize: 5, //每页的数据_年临时数据库
|
|
|
|
Result_currentPage: 1, //初始页_结果数据库
|
|
Result_pagesize: 5, //每页的数据_结果数据库
|
|
|
|
//是否在分析的时候就自动更新大类,小类的数据
|
|
chkAutoUpdate:true,
|
|
//当前运行分析的位置
|
|
curAnalyzePos: 0,
|
|
curAnalyzePos_Display:1,
|
|
//是否是暂停状态
|
|
isPause:false,
|
|
//当前需要分析的数据集
|
|
YearTempDataReady: [],
|
|
//确定查找到的表格数据
|
|
EnsureTableData: [],
|
|
//不确定查找的表格数据
|
|
UnsureTableData: [],
|
|
//查看运行结果数据集
|
|
ResultTableData: [],
|
|
//结论部分的时候的弹出框
|
|
dialogTableVisible: false,
|
|
//实时分析的时候的弹出框
|
|
RealTime_dialogTableVisible:false,
|
|
//实时的??
|
|
gridData1:[],
|
|
//结论部分查看数据分析表格
|
|
gridData: [],
|
|
|
|
//实时分析的时候查看分析表格
|
|
RealTime_gridData:[],
|
|
|
|
//搜索部分的设置值
|
|
result_year: '2021',
|
|
|
|
//当前的结果的选择的中间值传递方式
|
|
curResultSelectData: {},
|
|
|
|
//结果表格的查询内容相关的字段
|
|
form: {
|
|
AnalyzeStatus: "",
|
|
HaveEdit: "",
|
|
SP_DL: "",
|
|
SP_PZ: "",
|
|
SP_XL: "",
|
|
SP_YL: "",
|
|
YPMC: ""
|
|
},
|
|
|
|
//全部结果更新的查询数据条件
|
|
formResultApply: {
|
|
ApplyYearl:''
|
|
},
|
|
//全局替换结果实时情况展现
|
|
txtResultApply: '',
|
|
//全部结果更滑操作
|
|
isResultPause: false,
|
|
//开始循环的时候的位置
|
|
curResultApplyPos: 0
|
|
}
|
|
},
|
|
mounted() {
|
|
var _this = this; //this指向vue
|
|
Vue.prototype.$loading = this.loading
|
|
//this.GetDistinctYPMC();
|
|
this.GetDistinctDaLei();
|
|
_this.loading = false;
|
|
|
|
|
|
},
|
|
methods: {
|
|
|
|
//新的第四步应用操作
|
|
AA(row, rowIndex) {
|
|
//alert(index);
|
|
|
|
//row.masterID = rowIndex;
|
|
|
|
console.log('devset', row);
|
|
|
|
//this.fourth_data[rowIndex].SP_DL="测试"
|
|
|
|
//layer.msg('待开发中,等前面推荐分析的流程确认可以再进行该替换功能开发...')
|
|
//return;
|
|
|
|
var _this = this;
|
|
layer.confirm('您确定采纳该推断并且全部替换?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
},
|
|
function (index) {
|
|
if (this.curYear == "") {
|
|
layer.msg('请到第二步选择需要整体更新的年份!')
|
|
}
|
|
axios.get(Gaddress + '/Classify/ApplyFourthResult?strResult=' + JSON.stringify(row) + '&strMain=' + JSON.stringify(_this.fourth_data[rowIndex]) + '&RWNF=' + _this.curYear).then((res) => {
|
|
console.log('apply_result', res.data);
|
|
|
|
//再加个日志记录
|
|
addlog("智能替换", "原数据[" + JSON.stringify(row) + "],SQL命令[" + res.data.logsql+"]")
|
|
|
|
|
|
_this.fourth_data[rowIndex].SP_DL = res.data.data.SP_DL
|
|
_this.fourth_data[rowIndex].SP_YL = res.data.data.SP_YL
|
|
_this.fourth_data[rowIndex].SP_PZ = res.data.data.SP_PZ
|
|
_this.fourth_data[rowIndex].SP_XL = res.data.data.SP_XL
|
|
_this.fourth_data[rowIndex].EditTime = res.data.data.EditTime
|
|
|
|
|
|
|
|
layer.msg('采纳成功!')
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
BB(row) {
|
|
console.log('row.EditTime', row.EditTime);
|
|
if (row.EditTime == null) {
|
|
layer.msg('请先采纳最佳推荐!')
|
|
return;
|
|
}
|
|
},
|
|
//向导页设置
|
|
handleClick(tab, event) {
|
|
console.log(tab, event);
|
|
if (tab.index == "0") {
|
|
this.GetDistinctDaLei();
|
|
}
|
|
},
|
|
handleAnalyzeChange(value) {
|
|
console.log(value);
|
|
},
|
|
|
|
handleResultApplyChange(value) {
|
|
console.log(value);
|
|
},
|
|
|
|
//显示推荐结果
|
|
RealTime_handleEditClick(value) {
|
|
|
|
if (value.AnalyzeJson != "") {
|
|
this.RealTime_gridData = JSON.parse(value.AnalyzeJson);
|
|
} else {
|
|
this.RealTime_gridData = [];
|
|
}
|
|
|
|
//显示对话框
|
|
this.RealTime_dialogTableVisible = true
|
|
|
|
|
|
},
|
|
|
|
//第四步的修改推荐结果弹出框操作
|
|
handleEditResultClick(value) {
|
|
//console.log('kankankankan333', value.AnalyzeJson);
|
|
if (value.AnalyzeJson != "") {
|
|
this.curResultSelectData = value;
|
|
this.gridData = JSON.parse(value.AnalyzeJson);
|
|
} else {
|
|
this.curResultSelectData = {};
|
|
this.gridData = [];
|
|
}
|
|
|
|
//显示对话框
|
|
this.dialogTableVisible = true
|
|
|
|
},
|
|
|
|
//第四步的关闭弹出框
|
|
handleResultDialogClose() {
|
|
console.log('yun运行第四步的操作')
|
|
this.GetAnalyzeResult()
|
|
},
|
|
|
|
//第四步确认采纳方法按钮确认操作
|
|
handleAcceptClick(value,index) {
|
|
//进行服务端的推荐修订
|
|
//发送推荐内容到服务器完成修改;
|
|
console.log('value',value)
|
|
//本地同时进行调整
|
|
var _this = this; //this指向vue
|
|
|
|
layer.confirm('您确定采纳该推断?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
},
|
|
function (index) {
|
|
_this.loading = true;
|
|
|
|
//定义出来需要更新的类内容,先把当前的值拿出来
|
|
var curUpdateData = _this.curResultSelectData
|
|
//更新其中几个需更换的值
|
|
curUpdateData.SP_YL= value.SP_YL;
|
|
curUpdateData.SP_XL = value.SP_XL;
|
|
curUpdateData.SP_PZ = value.SP_PZ;
|
|
|
|
//进行服务端访问
|
|
axios({
|
|
url: Gaddress + '/Classify/UpdateYearTempAnalyze',
|
|
params: curUpdateData
|
|
}).then((res) => {
|
|
console.log('res',res);
|
|
|
|
//本地同时进行调整
|
|
//如果更新成功
|
|
if (res.data.count > 0) {
|
|
//更新弹出界面的数值
|
|
_this.$set(_this.curResultSelectData, 'SP_YL', res.data.data.SP_YL);
|
|
_this.$set(_this.curResultSelectData, 'SP_XL', res.data.data.SP_XL);
|
|
_this.$set(_this.curResultSelectData, 'SP_PZ', res.data.data.SP_PZ);
|
|
|
|
|
|
//更新主表格的数据,发现无需写代码,即可进行更新,同时因为不在同一个页面,更改方式为关闭窗口就刷新数据
|
|
//_this.$set(_this.ResultTableData,index, _this.curResultSelectData);
|
|
_this.showTip("更换成功!")
|
|
} else {
|
|
//更新没有成功
|
|
_this.showTip("更换没有成功,请检查!")
|
|
}
|
|
|
|
layer.close(index);
|
|
_this.loading = false;
|
|
});
|
|
|
|
},
|
|
//如果点击取消,保留方法
|
|
function() {
|
|
|
|
});
|
|
|
|
},
|
|
|
|
//初始页currentPage、初始每页数据数pagesize和数据data
|
|
handleSizeChange_Classify: function (size) {
|
|
this.Classify_pagesize = size
|
|
console.log(this.Classify_pagesize) //每页下拉显示数据
|
|
},
|
|
handleCurrentChange_Classify: function (currentPage) {
|
|
this.Classify_currentPage = currentPage
|
|
console.log(this.Classify_currentPage) //点击第几页
|
|
},
|
|
|
|
//初始页currentPage、初始每页数据数pagesize和数据data
|
|
handleSizeChange_YearTemp: function (size) {
|
|
this.YearTemp_pagesize = size
|
|
console.log(this.YearTemp_pagesize) //每页下拉显示数据
|
|
},
|
|
handleCurrentChange_YearTemp: function (currentPage) {
|
|
this.YearTemp_currentPage = currentPage
|
|
console.log(this.YearTemp_currentPage) //点击第几页
|
|
},
|
|
|
|
//初始页currentPage、初始每页数据数pagesize和数据data
|
|
handleSizeChange_Result: function (size) {
|
|
this.Result_pagesize = size
|
|
console.log(this.Result_pagesize) //每页下拉显示数据
|
|
},
|
|
handleCurrentChange_Result: function (currentPage) {
|
|
this.Result_currentPage = currentPage
|
|
console.log(this.Result_currentPage) //点击第几页
|
|
},
|
|
//显示进度内容
|
|
addNote(str) {
|
|
var aData = new Date().toLocaleString();;
|
|
this.textarea = aData + " " + str + '\r\n' + this.textarea;
|
|
},
|
|
//显示进度内容
|
|
addResultNote(str) {
|
|
var aData = new Date().toLocaleString();;
|
|
this.txtResultApply = aData + " " + str + '\r\n' + this.txtResultApply;
|
|
},
|
|
//显示提示信息
|
|
showTip(strmessage) {
|
|
this.$message({
|
|
message: strmessage,
|
|
type: 'warning'
|
|
});
|
|
},
|
|
|
|
//第一步的生成基础库
|
|
GenerateClassify() {
|
|
var _this = this; //this指向vue
|
|
if (_this.searchJson.years.length <= 0) {
|
|
layer.msg('您至少需要选择一个年份进行构建背景库数据生成');
|
|
return;
|
|
}
|
|
|
|
layer.confirm('您确定重新构建内容?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
}, function (index) {
|
|
_this.loading = true;
|
|
_this.showTip('数据正在重新构建,请等待...');
|
|
|
|
(async () => {
|
|
await axios({
|
|
url: Gaddress + '/Classify/GenerateClassifyDict',
|
|
params: {years: _this.searchJson.years.join(',')}
|
|
}).then((res) => {
|
|
console.log(res);
|
|
layer.msg("生成构建背景库数据成功");
|
|
//_this.addNote("此次" + desc + "替换操作完成," + res.data.data + "谢谢使用!");
|
|
//_this.search();
|
|
_this.loading = false;
|
|
|
|
//_this.btnLoading[btnid] = false;
|
|
});
|
|
})();
|
|
|
|
}, function () {
|
|
|
|
});
|
|
|
|
},
|
|
|
|
//第一步的获取样品名称下拉菜单的数据
|
|
GetFirstDynamicDistinctYPMC(query) {
|
|
_this = this;
|
|
axios({
|
|
url: "./Classify/GetFirstDynamicDistinctYPMC?str=" + query
|
|
}).then((res) => {
|
|
console.log('GetFirstDynamicDistinctYPMC', res.data.data)
|
|
//全部结果
|
|
_this.First_SelYPMCs = [];
|
|
_this.First_SelYPMCs = res.data.data;
|
|
console.log(' _this.First_SelYPMCs', _this.First_SelYPMCs);
|
|
});
|
|
},
|
|
//第一步的获取大类的下拉菜单的数据
|
|
GetDistinctDaLei() {
|
|
_this = this;
|
|
axios({
|
|
url: "./Classify/GetDistinctDaLei"
|
|
}).then((res) => {
|
|
console.log('GetDistinctDaLei', res.data.data)
|
|
//全部结果
|
|
_this.First_SelDaLeis = [];
|
|
_this.First_SelDaLeis = res.data.data;
|
|
console.log(' _this.First_SelDaLeis', _this.First_SelDaLeis);
|
|
});
|
|
},
|
|
//第一步的查询生成的基础分析数据库
|
|
SearchClassify() {
|
|
console.log('this.searchJson', this.searchJson.ypmc)
|
|
_this = this;
|
|
//this.GetDistinctDaLei();
|
|
layui.use(['table', 'util'], function () {
|
|
var table = layui.table;
|
|
var util = layui.util;
|
|
table.render({
|
|
elem: '#ClassifyTable'
|
|
, url: Gaddress + '/Classify/getClassifyDict'
|
|
, where: _this.searchJson
|
|
, parseData: function (res) { //res 即为原始返回的数据
|
|
return {
|
|
"code": res.code,
|
|
"data": res.data, //解析数据列表
|
|
"count": res.count
|
|
};
|
|
}
|
|
//, width: 800
|
|
, height: 500
|
|
,editTrigger: 'dblclick' // 触发编辑的事件类型(默认 click )。
|
|
, cols: [[
|
|
{ field: 'ID', width: 100, align: 'center', title: '编号', sort: true }
|
|
, { field: 'YPMC', width: '18%', align: 'center', title: '样品名称', sort: true, edit: 'text' }
|
|
, { field: 'SP_DL', width: '18%', align: 'center', title: '食品大类', sort: true, edit: 'text' }
|
|
, { field: 'SP_YL', width: '18%', align: 'center', title: '食品亚类', sort: true, edit: 'text' }
|
|
, { field: 'SP_PZ', width: '18%', align: 'center', title: '食品品种', sort: true, edit: 'text' }
|
|
, { field: 'SP_XL', width: '18%', align: 'center', title: '食品细类', sort: true, edit: 'text' }
|
|
|
|
]]
|
|
, page: true
|
|
, done: function (res, curr, count) {
|
|
//$("table").width("100 %")
|
|
|
|
|
|
}
|
|
});
|
|
|
|
|
|
// 单元格编辑后的事件
|
|
table.on('edit(ClassifyTable)', function (obj) {
|
|
var value = obj.value //得到修改后的值
|
|
, data = obj.data //得到所在行所有键值
|
|
, field = obj.field; //得到字段
|
|
|
|
console.log('value',value,'data',data,'field',field)
|
|
|
|
layer.confirm('您确定修改[' + obj.field + "||" + value + ']内容?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
}, function () {
|
|
axios({
|
|
url: Gaddress + '/Classify/UpdateSingleGrid_ClassifyDict',
|
|
params: {ID: data.ID, Field: field, Value: value}
|
|
}).then((res) => {
|
|
if (res.data.count>0) {
|
|
layer.msg('修改完成', { icon: 1 });
|
|
} else {
|
|
layer.msg('修改没有成功,请检查!', { icon: 1 });
|
|
}
|
|
})
|
|
|
|
|
|
}, function () {
|
|
//layer.msg('也可以这样', {
|
|
// time: 20000, //20s后自动关闭
|
|
// btn: ['明白了', '知道了']
|
|
//});
|
|
});
|
|
|
|
|
|
//layer.msg('[ID: ' + data.ID + '] ' + field + ' 字段更改值为:' + util.escape(value));
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
//第二步的需要分类的数据缓存操作
|
|
GenerateYearTempNew() {
|
|
var _this = this; //this指向vue
|
|
layer.confirm('您确定重新构建内容?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
}, function () {
|
|
|
|
|
|
_this.loading = true;
|
|
_this.showTip('年份数据正在重新构建,请等待...');
|
|
|
|
(async () => {
|
|
await axios({
|
|
url: Gaddress + '/Classify/GenerateYearTempDictNew?RWNF=' + $('#curYear').val() + '&SP_DL=' + $('#second_sp_dl').val()
|
|
}).then((res) => {
|
|
console.log(res.data.data);
|
|
|
|
var curMsg = res.data.data;
|
|
layer.msg("加入" + curMsg + "条数据");
|
|
|
|
//_this.addNote("此次" + desc + "替换操作完成," + res.data.data + "谢谢使用!");
|
|
_this.loading = false;
|
|
//_this.btnLoading[btnid] = false;
|
|
});
|
|
})();
|
|
|
|
}, function () {
|
|
|
|
});
|
|
|
|
},
|
|
|
|
//第二步的实时年度准备操作数据的查询
|
|
SearchYearReady() {
|
|
|
|
layui.use('table', function () {
|
|
var table = layui.table;
|
|
table.render({
|
|
elem: '#YearTempTable'
|
|
, url: Gaddress + '/Classify/GetYearDataReady'
|
|
, where: {'RWNF': $('#curYear').val(), 'SP_DL': $('#second_sp_dl').val()}
|
|
, parseData: function (res) { //res 即为原始返回的数据
|
|
return {
|
|
"code": res.code,
|
|
"data": res.data, //解析数据列表
|
|
"count": res.count
|
|
};
|
|
}
|
|
, height: 500
|
|
, cols: [[
|
|
{field: 'JC_id', width: 100, align: 'center', title: '编号', sort: true}
|
|
, { field: 'YPMC', width: '16%', align: 'center', title: '样品名称', sort: true, edit: 'text' }
|
|
, { field: 'SP_DL', width: '16%', align: 'center', title: '食品大类', sort: true, edit: 'text' }
|
|
, { field: 'SP_YL', width: '16%', align: 'center', title: '食品亚类', sort: true, edit: 'text' }
|
|
, { field: 'SP_XL', width: '16%', align: 'center', title: '食品细类', sort: true, edit: 'text' }
|
|
, { field: 'SP_PZ', width: '16%', align: 'center', title: '食品品种', sort: true, edit: 'text' }
|
|
|
|
]]
|
|
, page: true
|
|
, done: function (res, curr, count) {
|
|
//$("table").width("100 %")
|
|
|
|
|
|
}
|
|
});
|
|
|
|
// 单元格编辑后的事件
|
|
//table.on('edit(YearTempTable)', function (obj) {
|
|
// var value = obj.value //得到修改后的值
|
|
// , data = obj.data //得到所在行所有键值
|
|
// , field = obj.field; //得到字段
|
|
|
|
// console.log('value', value, 'data', data, 'field', field)
|
|
|
|
// layer.confirm('您确定修改[' + obj.field + "||" + value + ']内容?', {
|
|
// btn: ['确定', '取消'] //按钮
|
|
// }, function () {
|
|
// axios({ url: '/Classify/UpdateSingleGrid_YearTempDict', params: { ID: data.ID, Field: field, Value: value } }).then((res) => {
|
|
// if (res.data.count > 0) {
|
|
// layer.msg('修改完成', { icon: 1 });
|
|
// } else {
|
|
// layer.msg('修改没有成功,请检查!', { icon: 1 });
|
|
// }
|
|
// })
|
|
|
|
// }, function () {
|
|
|
|
// });
|
|
//});
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
//第二步的查询生成的年度临时库,已经弃用
|
|
SearchYearTemp() {
|
|
console.log('curYear', $('#curYear').val())
|
|
//console.log('this.searchJson', this.searchJson.ypmc)
|
|
_this = this;
|
|
layui.use('table', function () {
|
|
var table = layui.table;
|
|
table.render({
|
|
elem: '#YearTempTable'
|
|
, url: Gaddress + '/Classify/GetYearTempDict'
|
|
, where: { 'RWNF': $('#curYear').val() }
|
|
, parseData: function (res) { //res 即为原始返回的数据
|
|
return {
|
|
"code": res.code,
|
|
"data": res.data, //解析数据列表
|
|
"count": res.count
|
|
};
|
|
}
|
|
, height: 500
|
|
, cols: [[
|
|
{ field: 'ID', width: 100, align: 'center', title: '编号', sort: true }
|
|
, { field: 'YPMC', width: '33%', align: 'center', title: '样品名称', sort: true, edit: 'text' }
|
|
, { field: 'SP_DL', width: '33%', align: 'center', title: '食品大类', sort: true, edit: 'text' }
|
|
|
|
]]
|
|
, page: true
|
|
, done: function (res, curr, count) {
|
|
//$("table").width("100 %")
|
|
|
|
|
|
}
|
|
});
|
|
|
|
// 单元格编辑后的事件
|
|
table.on('edit(YearTempTable)', function (obj) {
|
|
var value = obj.value //得到修改后的值
|
|
, data = obj.data //得到所在行所有键值
|
|
, field = obj.field; //得到字段
|
|
|
|
console.log('value', value, 'data', data, 'field', field)
|
|
|
|
layer.confirm('您确定修改[' + obj.field + "||" + value + ']内容?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
}, function () {
|
|
axios({
|
|
url: Gaddress + '/Classify/UpdateSingleGrid_YearTempDict',
|
|
params: {ID: data.ID, Field: field, Value: value}
|
|
}).then((res) => {
|
|
if (res.data.count > 0) {
|
|
layer.msg('修改完成', { icon: 1 });
|
|
} else {
|
|
layer.msg('修改没有成功,请检查!', { icon: 1 });
|
|
}
|
|
})
|
|
|
|
}, function () {
|
|
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
//第三步的全局同步最新分类库
|
|
//pubserver
|
|
UpgradeFenLeiKu() {
|
|
layer.msg('开始操作导出,请等待');
|
|
|
|
alert("将导食品分类数据到SQLSERVER数据库");
|
|
let curData = [];//定义初始化数据集
|
|
|
|
//第一个网络访问,获取所有数据
|
|
axios.get(pubserver + 'SPLB_DB').then((res) => {
|
|
res.data.value.forEach(function (datanf, index) {
|
|
if (datanf.Pid == "Z3000") {
|
|
datanf.Json.forEach(function (datadl, index) {
|
|
datadl.SPYL.forEach(function (datayl) {
|
|
datayl.SPZL.forEach(function (datazl) {
|
|
datazl.SPXL.forEach(function (dataxl) {
|
|
var JCXMJson = {
|
|
"SP_DL": datadl.SPDL,
|
|
"SP_YL": datayl.name,
|
|
"SP_PZ": datazl.name,
|
|
"SP_XL": dataxl.name,
|
|
"isUse": dataxl.typeName
|
|
}
|
|
|
|
if (Enumerable.From(curData).Where(function (x) {
|
|
return x.食品大类 == datadl.SPDL && x.食品亚类 == datayl.name && x.食品小类 == datazl.name && x.食品细类 == dataxl.name;
|
|
}).ToArray().length == 0
|
|
) {
|
|
//只有当查找之后发现不存在的这条数据才会进行记录并且导出
|
|
curData.push(JCXMJson);
|
|
}
|
|
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}
|
|
})
|
|
|
|
|
|
//第二个网络访问,提交数据
|
|
console.log('curdata', curData)
|
|
axios.post(Gaddress + '/Classify/ExportFenLei', {strJson: JSON.stringify(curData)}).then(function (res) {
|
|
console.log(res);
|
|
//dLaye.msg(res.data.msg)
|
|
layer.msg('操作完成[' + res.data.msg + ']');
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
//第三步获取准备分析的数据
|
|
GetYearDataReady() {
|
|
var _this = this; //this指向vue
|
|
axios({
|
|
url: "./Classify/GetYearTempDictReady"
|
|
}).then((res) => {
|
|
this.YearTempDataReady = res.data.data;
|
|
console.log(res.data.data)
|
|
_this.addNote("获取当前的待处理数据完成,共有" + res.data.count + '种类型数据需要处理');
|
|
console.log(res);
|
|
});
|
|
},
|
|
|
|
//第三步开始数据识别操作
|
|
StartAnalyze() {
|
|
//首先判断目前是否已经加载需要的所有的准备数据
|
|
|
|
var _this = this; //this指向vue
|
|
if (_this.YearTempDataReady.length <= 0) {
|
|
_this.addNote("请先点击获取数据操作");
|
|
return;
|
|
}
|
|
_this.isPause = false;
|
|
|
|
(async () => {
|
|
for (var i = _this.curAnalyzePos; i < _this.YearTempDataReady.length; i++) {
|
|
|
|
//如果发现按了暂停
|
|
if (_this.isPause == true) {
|
|
return;
|
|
}
|
|
_this.curAnalyzePos = i;
|
|
_this.curAnalyzePos_Display = i+1;
|
|
console.log('_this.YearTempDataReady[i].SP_DL', _this.YearTempDataReady[i].SP_DL)
|
|
await axios({
|
|
url: "./Classify/GetClassifyCompare_ExportFenLeiBase?YPMC=" + _this.YearTempDataReady[i].YPMC
|
|
+ "&SP_DL=" + _this.YearTempDataReady[i].SP_DL
|
|
+ "&SP_YL=" + _this.YearTempDataReady[i].SP_YL
|
|
+ "&SP_XL=" + _this.YearTempDataReady[i].SP_XL
|
|
+ "&SP_PZ=" + _this.YearTempDataReady[i].SP_PZ
|
|
}).then((res) => {
|
|
|
|
if (res.data.count > 0) {
|
|
//历史库修改
|
|
_this.EnsureTableData.push(res.data.data)
|
|
} else {
|
|
debugger;
|
|
_this.UnsureTableData.push({
|
|
'ypmc': _this.YearTempDataReady[i].YPMC,
|
|
'sp_dl': _this.YearTempDataReady[i].SP_DL,
|
|
'sp_yl': _this.YearTempDataReady[i].SP_YL,
|
|
'sp_xl': _this.YearTempDataReady[i].SP_XL,
|
|
'sp_pz': _this.YearTempDataReady[i].SP_PZ,
|
|
'AnalyzeJson': ''
|
|
})
|
|
|
|
//axios({
|
|
// url: "./Classify/GetZhiNengFenLei?strQuery=" + _this.YearTempDataReady[i].YPMC + "&YPMC=" + _this.YearTempDataReady[i].YPMC + "&SP_DL=" + _this.YearTempDataReady[i].SP_DL + "&AutoUpdate=" + (_this.chkAutoUpdate?1:0)
|
|
//}).then((res_es) => {
|
|
|
|
// console.log('res_es.data',res_es.data)
|
|
// //推荐库修改
|
|
// _this.UnsureTableData.push({
|
|
// 'YPMC': res_es.data.data.YPMC,
|
|
// 'SP_DL': res_es.data.data.SP_DL,
|
|
// 'SP_YL': res_es.data.data.SP_YL,
|
|
// 'SP_XL': res_es.data.data.SP_XL,
|
|
// 'SP_PZ': res_es.data.data.SP_PZ,
|
|
// 'AnalyzeJson': res_es.data.data.AnalyzeJson
|
|
// })
|
|
//});
|
|
|
|
}
|
|
|
|
_this.addNote("第" + (i + 1).toString() + "/" + _this.YearTempDataReady.length + "个完成," + ((res.data.count>0)?"历史库对应":"历史库无信息"));
|
|
console.log(res);
|
|
if (i == (_this.YearTempDataReady.length - 1)) {
|
|
_this.addNote("此次操作全部完成,谢谢使用!");
|
|
_this.loading = false;
|
|
}
|
|
});
|
|
}
|
|
})();
|
|
},
|
|
PauseAnalyze() {
|
|
this.isPause = true;
|
|
this.showTip('已经暂停分析');
|
|
},
|
|
ResetAnalyze() {
|
|
this.isPause = true;
|
|
this.curAnalyzePos = 0;
|
|
this.curAnalyzePos_Display = 1;
|
|
this.textarea = "";
|
|
this.YearTempDataReady = [];
|
|
this.EnsureTableData = [];
|
|
this.UnsureTableData = [];
|
|
this.showTip('已经重置操作');
|
|
|
|
},
|
|
|
|
//新的第四步获取需要智能分析及推荐的数据
|
|
GetFourthAnalyzeData() {
|
|
this.fourth_data = []
|
|
this.fourth_data_result=[]
|
|
|
|
axios.get("./classify/GetFourth_AnalyzeData").then(res => {
|
|
console.log('this.fourth_data', res.data.data);
|
|
this.fourth_data = res.data.data;
|
|
|
|
this.fourth_data.forEach((res, index) => {
|
|
if (res.AnalyzeJson != null) {
|
|
this.fourth_data_result.push(JSON.parse(res.AnalyzeJson).slice(0, 10))
|
|
} else {
|
|
this.fourth_data_result.push([])
|
|
}
|
|
|
|
})
|
|
//console.log('rrrr,AnalyzeJson', this.fourth_data_result);
|
|
this.addFourthNote("获取当前的待处理数据完成,共有" + this.fourth_data.length + '条数据需要处理');
|
|
})
|
|
},
|
|
//新的第四步表格数据格式化
|
|
formatterAnalyzeStatus({ cellValue }) {
|
|
let item = this.AnalyzeList.find(item => item.value === cellValue)
|
|
return item ? item.label : ''
|
|
},
|
|
//新的第四步的显示进度内容
|
|
addFourthNote(str) {
|
|
var aData = new Date().toLocaleString();
|
|
this.textarea_fourth = aData + " " + str + '\r\n' + this.textarea_fourth;
|
|
},
|
|
//新的第四步进行智能比对操作
|
|
StartFourthAnalyze() {
|
|
//首先判断目前是否已经加载需要的所有的准备数据
|
|
var _this = this; //this指向vue
|
|
if (_this.fourth_data.length <= 0) {
|
|
_this.addFourthNote("请先点击获取需要智能分析的数据");
|
|
return;
|
|
}
|
|
_this.isFourthPause = false;
|
|
i = 0;
|
|
(async () => {
|
|
for (var i = _this.curFourthAnalyzePos; i < _this.fourth_data.length; i++) {
|
|
//如果发现按了暂停
|
|
if (_this.isFourthPause == true) {
|
|
return;
|
|
}
|
|
_this.curFourthAnalyzePos = i;
|
|
_this.curFourthAnalyzePos_Display = i+1;
|
|
//console.log ('_this.fourth_data[i].YPMC', _this.fourth_data[i].YPMC, _this.fourth_data[i].SP_DL)
|
|
//设置背景库的比对,如果有就提醒出来
|
|
await axios({
|
|
url: "./Classify/GetAnalyzeFromBeiJingKu?id=" + _this.fourth_data[i].ID + "&YPMC=" + _this.fourth_data[i].YPMC
|
|
+ "&SP_DL=" + _this.fourth_data[i].SP_DL
|
|
}).then((res) => {
|
|
|
|
console.log('test_GetAnalyzeFromBeiJingKu', res);
|
|
if (res.data.count > 0) {
|
|
//增加到界面表格数据
|
|
_this.fourth_data_result[i] = JSON.parse(res.data.data.analyzejson)
|
|
//再做个显示确认按钮
|
|
|
|
} else {
|
|
axios({
|
|
url: "./Classify/GetZhiNengFenLei?id=" + _this.fourth_data[i].ID +"&strQuery=" + _this.fourth_data[i].YPMC + "&YPMC=" + _this.fourth_data[i].YPMC + "&SP_DL=" + _this.fourth_data[i].SP_DL
|
|
}).then((res_es) => {
|
|
|
|
//console.log('res_es.data', res_es.data.data.AnalyzeJson)
|
|
//推荐库修改
|
|
_this.fourth_data_result[i] = JSON.parse(res_es.data.data.analyzejson);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_this.addFourthNote("第" + (i + 1).toString() + "/" + _this.fourth_data.length + "个完成," + ((res.data.count > 0) ? "背景库对应" : "智能推荐"));
|
|
console.log(res);
|
|
if (i == (_this.fourth_data.length - 1)) {
|
|
_this.addFourthNote("此次智能分析操作全部完成,请点击[获取需要推荐数据]按钮进行数据结果刷新,谢谢使用!");
|
|
console.log('_this.fourth_data_result', _this.fourth_data_result);
|
|
_this.loading = false;
|
|
|
|
layer.msg('智能推荐分析已经完成,会按照评分机制进行排序,请点击[分析查看]按钮进行查看推荐并应用满足条件的结果!', {
|
|
time: 0 //不自动关闭
|
|
,icon: 6
|
|
, btn: ['确定']
|
|
, yes: function (index) {
|
|
_this.GetFourthAnalyzeData()
|
|
layer.close(index);
|
|
|
|
}
|
|
});
|
|
|
|
//_that = _this;
|
|
//setTimeout(_that.GetFourthAnalyzeData(), 5000);
|
|
}
|
|
});
|
|
}
|
|
})();
|
|
},
|
|
|
|
|
|
//新的第四步暂停操作
|
|
PauseFourthAnalyze() {
|
|
this.isFourthPause = true;
|
|
this.showTip('已经暂停分析');
|
|
},
|
|
//新的第四步初始化操作
|
|
ResetFourthAnalyze() {
|
|
this.isFourthPause = true;
|
|
this.curFourthAnalyzePos = 0;
|
|
this.textFourtharea = "";
|
|
this.fourth_data = [];
|
|
this.fourth_data_result = [];
|
|
this.textarea_fourth = "";
|
|
this.curFourthAnalyzePos = 0;
|
|
this.curFourthAnalyzePos_Display = 1;
|
|
//this.EnsureTableData = [];
|
|
//this.UnsureTableData = [];
|
|
this.showTip('已经重置操作');
|
|
|
|
},
|
|
|
|
//新的第四步的智能分析模型更新-动态智能数据ES的增量构建
|
|
UpgradeFenXiMoXing() {
|
|
layer.msg('开始智能分析模型更新,请等待');
|
|
|
|
axios.post(Gaddress + '/Classify/SetElasticImport').then(function (res) {
|
|
console.log(res);
|
|
//dLaye.msg(res.data.msg)
|
|
if (res.data.data == 200) {
|
|
layer.msg('智能分析模型更新操作完成[' + res.data.msg + ']');
|
|
} else {
|
|
layer.msg('智能分析模型更新操作需要检查!');
|
|
}
|
|
|
|
})
|
|
},
|
|
|
|
|
|
|
|
//第四步的标头显示
|
|
headerCellClassName({ column, columnIndex }) {
|
|
//if (column.property === 'name') {
|
|
// return 'col-blue'
|
|
//}
|
|
return 'col-blue'
|
|
},
|
|
|
|
handleFourthAnalyzeChange() {
|
|
console.log('changefourthmain');
|
|
},
|
|
|
|
|
|
|
|
//第四步获取推断的结论设置,加了一个刷新是否回到第一页的isBackPage的变量
|
|
GetAnalyzeResult(isBackPage) {
|
|
|
|
//console.log('form222', this.form);
|
|
|
|
var _this = this; //this指向vue
|
|
_this.loading = true;
|
|
axios({
|
|
url: "./Classify/GetResultDict", params:_this.form
|
|
}).then((res) => {
|
|
//console.log('res_es.data', res.data.data)
|
|
//全部结果
|
|
_this.ResultTableData = res.data.data;
|
|
if (isBackPage) {
|
|
_this.Result_currentPage = 1;
|
|
}
|
|
_this.loading = false;
|
|
//console.log('ResultTableData', this.ResultTableData)
|
|
});
|
|
},
|
|
|
|
|
|
//第四步实现按照年份应用
|
|
ResultApplyByYear() {
|
|
//console.log('formResultApply', this.formResultApply.ApplyYear)
|
|
_this = this;
|
|
var curResultYear = this.formResultApply.ApplyYear;
|
|
layer.confirm('您确定进行该年份采纳推断操作?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
},
|
|
function (index) {
|
|
layer.close(index);
|
|
console.log('_this',_this)
|
|
_this.isResultPause = false;
|
|
|
|
//开始循环的部分
|
|
_this.addResultNote("开始替换操作,替换任务年份为" + curResultYear + "年的数据,共有" + _this.ResultTableData.length + "种分类需要刷新");
|
|
|
|
//全局异步大循环
|
|
(async () => {
|
|
for (var i = _this.curResultApplyPos; i <= _this.ResultTableData.length; i++) {
|
|
|
|
let curUpdate = _this.ResultTableData[i];
|
|
curUpdate.RWNF = curResultYear
|
|
//如果发现按了暂停
|
|
if (_this.isResultPause == true) {
|
|
return;
|
|
}
|
|
_this.curResultApplyPos = i;
|
|
await axios.post(
|
|
"./Classify/UpdateResultByYear",
|
|
curUpdate
|
|
).then((res) => {
|
|
if (res.data.count > 0) {
|
|
_this.addResultNote("任务年份:" + _this.formResultApply.ApplyYear + "年,样品名称:" + _this.ResultTableData[i].YPMC + ",食品大类:" + _this.ResultTableData[i].SP_DL + "全局替换" + res.data.count + "条完成")
|
|
} else {
|
|
_this.addResultNote("任务年份:" + _this.formResultApply.ApplyYear + "年,样品名称:" + _this.ResultTableData[i].YPMC + ",食品大类:" + _this.ResultTableData[i].SP_DL + "全局替换没有成功")
|
|
}
|
|
})
|
|
}
|
|
})()
|
|
|
|
_this.addResultNote("替换操作全部完成")
|
|
//_this.loading = false;
|
|
|
|
|
|
|
|
|
|
},
|
|
function () { }
|
|
)
|
|
|
|
//实验性代码,暂时保留
|
|
////第四步被调用应用的方法
|
|
//_this.ResultApplyByYear_Fuction = function (that) {
|
|
|
|
// console.log('that',that)
|
|
// //alert('内部第哦啊哦那个')
|
|
// _this.addNote("开始替换操作,替换任务年份为" + that.formResultApply.ApplyYear + "年的数据,共有" + that.ResultTableData + "种分类需要刷新" )
|
|
|
|
// //全局异步大循环
|
|
// (async () => {
|
|
// for (var i = 0; i <= _this.ResultTableData.length; i++) {
|
|
|
|
// //如果发现按了暂停
|
|
// if (_this.isResultPause == true) {
|
|
// return;
|
|
// }
|
|
// await axios({
|
|
// url: "./Classify/UpdateResultByYear",
|
|
// params: _this.ResultTableData[i]
|
|
// }).then((res) => {
|
|
// if (res.data.count == 0) {
|
|
// _this.addNote("任务年份:" + _this.formResultApply.ApplyYear + "年,样品名称:" + _this.ResultTableData[i].YPMC + ",食品大类:" + _this.ResultTableData[i].SP_DL + "全局替换完成")
|
|
// } else {
|
|
// _this.addNote("任务年份:" + _this.formResultApply.ApplyYear + "年,样品名称:" + _this.ResultTableData[i].YPMC + ",食品大类:" + _this.ResultTableData[i].SP_DL +"全局替换没有成功")
|
|
// }
|
|
// })
|
|
// }
|
|
// })()
|
|
|
|
// _this.addNote("替换操作全部完成")
|
|
|
|
|
|
//}
|
|
|
|
},
|
|
|
|
//第四步单独结果的应用
|
|
handleSingleResultUpdateClick(value,index) {
|
|
_this = this;
|
|
var curResultYear = this.formResultApply.ApplyYear;
|
|
layer.confirm('您确定进行该年份采纳推断操作?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
},
|
|
function (index) {
|
|
layer.close(index);
|
|
|
|
let curUpdate = _this.ResultTableData[index];
|
|
curUpdate.RWNF = curResultYear
|
|
|
|
axios.post(
|
|
"./Classify/UpdateResultByYear",
|
|
curUpdate
|
|
).then((res) => {
|
|
if (res.data.count > 0) {
|
|
_this.addResultNote("任务年份:" + _this.formResultApply.ApplyYear + "年,样品名称:" + _this.ResultTableData[i].YPMC + ",食品大类:" + _this.ResultTableData[i].SP_DL + "全局替换" + res.data.count + "条完成")
|
|
} else {
|
|
_this.addResultNote("任务年份:" + _this.formResultApply.ApplyYear + "年,样品名称:" + _this.ResultTableData[i].YPMC + ",食品大类:" + _this.ResultTableData[i].SP_DL + "全局替换没有成功")
|
|
}
|
|
})
|
|
},
|
|
function () { }
|
|
)
|
|
},
|
|
|
|
//第四步全局应用暂停
|
|
ResultApplyPauseAnalyze() {
|
|
this.isResultPause = true;
|
|
this.showTip('已经暂停结果应用');
|
|
},
|
|
|
|
//第四步全局应用重置
|
|
ResultApplyResetAnalyze() {
|
|
this.isResultPause = true;
|
|
this.curAnalyzePos = 0;
|
|
this.curAnalyzePos_Display = 1;
|
|
this.txtResultApply = "";
|
|
this.showTip('已经重置结果应用');
|
|
},
|
|
}
|
|
})
|
|
///////////////////////////////////////////////////
|
|
|
|
|
|
//加上日志20211109
|
|
function addlog(otype, ocontent, ouser) {
|
|
var curUser = "";
|
|
if (sessionStorage['userName'] != null) {
|
|
curUser = sessionStorage['userName']
|
|
} else {
|
|
curUser = ouser
|
|
}
|
|
|
|
$.get(Gaddress + "/operatelog/addlog?ouser=" + curUser + "&otype=" + otype + "&ocontent=" + ocontent.substring(0, 2500), {})
|
|
.then(function (e) { return true })
|
|
}
|
|
|
|
|