-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path054dc5c9463e416bb955033b0bec74ab_bkn73tcx.js
199 lines (199 loc) · 7.13 KB
/
054dc5c9463e416bb955033b0bec74ab_bkn73tcx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
let AbstractAPIHandler = require("AbstractAPIHandler");
class MyAPIHandler extends AbstractAPIHandler {
execute(request) {
//部门编码
let dept_code = request.dept_code;
//会计期间
let kjqj = substring(request.kjqj, 0, 7);
//项目编号
let projectCode = request.projectCode;
let benqicjSql1 = "";
let benqicjSql2 = "";
let benqicjSql3 = "";
let benqiqsSql1 = "";
let benqiqsSql2 = "";
let benqiqsSql3 = "";
let benqizfsql = "";
if (dept_code != "D") {
benqicjSql1 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_code='" +
dept_code +
"' and document_status in('1','2') and baogaori leftlike '" +
kjqj +
"'";
benqicjSql2 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_code='" +
dept_code +
"' and document_status in('3','4') and baogaori!=null and update_data leftlike '" +
kjqj +
"'";
benqiqsSql1 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_code='" +
dept_code +
"' and document_status in('1','2') and qianshouri leftlike '" +
kjqj +
"'";
benqiqsSql2 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_code='" +
dept_code +
"' and document_status in('3','4') and qianshouri!=null and update_data leftlike '" +
kjqj +
"'";
benqizfsql =
"select count(1) totbg,dept_code,baogaobianma,sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0" +
" and dept_code='" +
dept_code +
"' and ziduan2='" +
projectCode +
"' and document_status='3' and update_data leftlike '" +
kjqj +
"' group by baogaobianma having count(1)>1";
} else {
benqicjSql1 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_name like '材料部' and document_status in('1','2') and baogaori leftlike '" +
kjqj +
"'";
benqicjSql2 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_name like '材料部' and document_status in('3','4') and baogaori!=null and update_data leftlike '" +
kjqj +
"'";
benqiqsSql1 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_name like '材料部' and document_status in('1','2') and qianshouri leftlike '" +
kjqj +
"'";
benqiqsSql2 =
"select sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0 and ziduan2='" +
projectCode +
"'" +
" and dept_name like '材料部' and document_status in('3','4') and qianshouri!=null and update_data leftlike '" +
kjqj +
"'";
benqizfsql =
"select count(1) totbg,'D'as dept_code,baogaobianma,sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0" +
" and dept_name like '材料部' and ziduan2='" +
projectCode +
"' and document_status='3' and update_data leftlike '" +
kjqj +
"' group by baogaobianma having count(1)>1";
}
let bqbgje = new Object();
let bqcjres1 = ObjectStore.queryByYonQL(benqicjSql1);
let bqcjres2 = ObjectStore.queryByYonQL(benqicjSql2);
let bqqsres1 = ObjectStore.queryByYonQL(benqiqsSql1);
let bqqsres2 = ObjectStore.queryByYonQL(benqiqsSql2);
let bqcjbgje = 0;
let bqqsbjje = 0;
if (bqcjres1.length > 0) {
bqcjbgje += bqcjres1[0].baogaojine;
}
if (bqcjres2.length > 0) {
bqcjbgje += bqcjres2[0].baogaojine;
}
if (bqqsres1.length > 0) {
bqqsbjje += bqqsres1[0].baogaojine;
}
if (bqqsres2.length > 0) {
bqqsbjje += bqqsres2[0].baogaojine;
}
let benqizfRes = ObjectStore.queryByYonQL(benqizfsql);
let qszfSql = "";
let cjzfsql = "";
var newRes = new Array();
let bgbm = "";
if (benqizfRes.length > 0) {
benqizfRes.forEach((e) => {
bgbm = bgbm + "'" + e.baogaobianma + "'" + ",";
});
bgbm = substring(bgbm, 0, bgbm.length - 1);
}
if (benqizfRes.length > 0) {
if (dept_code != "D") {
qszfSql =
"select ziduan2,dept_code,sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0" +
" and dept_code='" +
dept_code +
"' and ziduan2='" +
projectCode +
"' and document_status='2' and baogaobianma in(" +
bgbm +
") and qianshouri!=null and LEFT(qianshouri,7) != '" +
kjqj +
"' and update_data leftlike '" +
kjqj +
"' group by ziduan2";
cjzfsql =
"select ziduan2,dept_code,sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0" +
" and dept_code='" +
dept_code +
"' and ziduan2='" +
projectCode +
"' and document_status='2' and baogaobianma in(" +
bgbm +
") and baogaori!=null and LEFT(baogaori,7) != '" +
kjqj +
"' and update_data leftlike '" +
kjqj +
"' group by ziduan2";
} else {
qszfSql =
"select ziduan2,'D' as dept_code,sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0" +
" and dept_name like '材料部' and ziduan2='" +
projectCode +
"' and document_status='2' and baogaobianma in(" +
bgbm +
") and qianshouri!=null and LEFT(qianshouri,7) != '" +
kjqj +
"' and update_data leftlike '" +
kjqj +
"' group by ziduan2";
cjzfsql =
"select ziduan2,'D' as dept_code,sum(baogaojine) baogaojine from GT59740AT1.GT59740AT1.RJ001 where dr=0" +
" and dept_name like '材料部' and ziduan2='" +
projectCode +
"' and document_status='2' and baogaobianma in(" +
bgbm +
") and baogaori!=null and LEFT(baogaori,7) != '" +
kjqj +
"' and update_data leftlike '" +
kjqj +
"' group by ziduan2";
}
let zfqsRes = ObjectStore.queryByYonQL(qszfSql);
let zfcjRes = ObjectStore.queryByYonQL(cjzfsql);
if (zfqsRes.length > 0) {
bqqsbjje += zfqsRes[0].baogaojine;
}
if (zfcjRes.length > 0) {
bqcjbgje += zfcjRes[0].baogaojine;
}
}
bqbgje.bqcjbgje = MoneyFormatReturnBd(bqcjbgje / 1.06, 2);
bqbgje.bqqsbjje = MoneyFormatReturnBd(bqqsbjje / 1.06, 2);
bqbgje.dept_code = dept_code;
bqbgje.kjqj = kjqj;
bqbgje.projectCode = projectCode;
return { bqbgje };
}
}
exports({ entryPoint: MyAPIHandler });