scott_test.js 2.46 KB
Newer Older
Scott Sun's avatar
Scott Sun committed
1

Scott Sun's avatar
s  
Scott Sun committed
2 3 4 5 6
/*
NAME: 
DESCRIPTION: ;
PARAMETER:
    [
Scott Sun's avatar
Scott Sun committed
7 8 9 10 11 12 13 14 15 16 17 18
		{
            name : 'auto_save',
			title : '自动保存',
            type : 'RadioBox',
            property : {
				item_list:[
					{name:'yes',text:'YES'},
					{name:'no',text:'NO'},
				],
				tool_tip:'是否自动保存料号开关'
			}
        }
Scott Sun's avatar
s  
Scott Sun committed
19 20 21
	]
	
 VERSION_HISTORY:
Scott Sun's avatar
Scott Sun committed
22
	V1.00 2020-04-20 Scott Sun
Scott Sun's avatar
s  
Scott Sun committed
23 24 25 26 27
	    1.新版本
		
 HELP:
 	<html><body bgcolor="#DDECFE">
		<font size="3" color="#003DB2"><p>功能简介</p></font>
Scott Sun's avatar
Scott Sun committed
28
		<p> scott test </p>
Scott Sun's avatar
s  
Scott Sun committed
29 30
		<br>
		<font size="3" color="#003DB2"><p>参数配置</p></font>
Scott Sun's avatar
Scott Sun committed
31
		<p> 外形层 </p>
Scott Sun's avatar
s  
Scott Sun committed
32 33 34 35 36 37
		<br>
		<font size="3" color="#003DB2"><p>注意事项</p></font>
		<p> 无 </p>
		<br>
	</body></html>	
*/
Scott Sun's avatar
Scott Sun committed
38 39 40

console.log("---------------scott----------------");

Scott Sun's avatar
s  
Scott Sun committed
41 42 43 44
// 引入模块 包
var $ = require('topcam.scriptfunc').argv();
var fs = require('fs');
var _ = require('lodash');
Scott Sun's avatar
Scott Sun committed
45 46 47
var mode = $.ikm ? "topcam" : "aimdfm";
var IKM = $.ikm;
if (IKM==undefined ) { IKM = require('topcam.ikm6')($) }
Scott Sun's avatar
s  
Scott Sun committed
48
var GEN = $.gen;
Scott Sun's avatar
Scott Sun committed
49 50
var GUI = $.gui || {};
var Job = $.job || $.job_name;
Scott Sun's avatar
s  
Scott Sun committed
51
var JobId = $.job_id;
Scott Sun's avatar
Scott Sun committed
52 53 54 55 56
var db = $.db || {}
var PAR = {}
if ($.par) {
	PAR = $.par
} else if ($.hasOwnProperty('script_parameter')){
Scott Sun's avatar
s  
Scott Sun committed
57 58
	PAR = JSON.parse($.script_parameter);
}
Scott Sun's avatar
Scott Sun committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
if (mode === "aimdfm") {
	var database = require("topsin.database");
	database.addConnection($.conf.database_conf, "DFM");
	var QDfm = database.query("DFM");
	$.QDfm = QDfm;
	if ($.conf.product_type == "aimdfm") {
		QDfm.updateRow({
			table: "pdm_aimdfm_task",
			data: {
				current_process_title: $.process_title
			},
			where: { id: $.task_id }
		});
	}
}
var Status = 'ok';
var resultData = [];
Scott Sun's avatar
s  
Scott Sun committed
76
try {
Scott Sun's avatar
s  
Scott Sun committed
77

Scott Sun's avatar
Scott Sun committed
78 79 80 81 82 83 84 85 86
	
	var path = GEN.getJobPath({job:Job})

	console.log("----------------path---------------");
	console.log(path);
	



Scott Sun's avatar
s  
Scott Sun committed
87

Scott Sun's avatar
Scott Sun committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113


	if (mode === "aimdfm") {
		$.QDfm.updateRow({
			table: "pdm_aimdfm_task",
			data: {
				progress: 33.33
			},
			where: { id: $.task_id }
		});
		if (GEN.hasError()) {
			Status = 'error';
			resultData.push({ type: "error", title: "GEN错误!", detail: [{ desc: _.join(GEN.STATUS, "\n") }] });
			return {
				status: Status,
				result_data: resultData
			};
		} else {
			resultData.push({ type: "info", title: "操作完成, 请注意检查!" });
			return {
				status: Status,
				result_data: resultData
			};
		}
	}else {
		return "Done"
Scott Sun's avatar
s  
Scott Sun committed
114
	}
Scott Sun's avatar
Scott Sun committed
115
} catch (e) {
Scott Sun's avatar
s  
Scott Sun committed
116
	Status = 'error';
Scott Sun's avatar
Scott Sun committed
117 118
	resultData.push({type: "error", title: "脚本执行出错!", detail: [{desc: _.toString(e)}]});
	return (mode === "aimdfm") ? {status: Status, result_data: resultData} : "Error";
Scott Sun's avatar
s  
Scott Sun committed
119
}