diaoboSLReject.jsp
4.74 KB
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
<%--
Created by IntelliJ IDEA.
User: zhaiyaqi
Date: 2020/3/15
Time: 7:34 PM
To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.alibaba.fastjson.JSON" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.io.ByteArrayOutputStream" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="weaver.conn.RecordSetDataSource" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="kry.sql.util.StringUtil" %>
<%@ page import="java.util.Collections" %>
<%@ page import="emo.macro.ob.OB" %>
<%@ page import="java.util.Vector" %>
<%@ page import="java.math.BigDecimal" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
response.setContentType("application/json;charset=utf-8");
out.clear();
writeLog("【开始调用调拨修退回数量接口】:");
JSONObject result = new JSONObject(true);
result.put("code", -1);
String[] array = null;
String jsonStr = null;
try {
array = request.getParameterValues("array");
writeLog("接收参数: array:"+JSONObject.toJSONString(array));
if (array.length == 0){
result.put("message", "传递参数为空");
out.print(result.toJSONString());
return ;
}
} catch (Exception e) {
e.printStackTrace();
result.put("message", "获取参数异常");
out.print(result.toJSONString());
return;
}
for (int i=0;i<array.length;i++) {
JSONArray jsons = JSONArray.parseArray(array[i]);
writeLog("JSON=" + jsons);
for (int j = 0; j < jsons.size(); j++) {
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
JSONObject jsonObject = jsons.getJSONObject(j);
String modeId = jsonObject.get("modeId").toString();
String modoNum = jsonObject.get("modeNum").toString();
String sql;
//先查询现有的数量
sql = "select sl from uf_wzdbptbz where id ='"+modeId+"'";
writeLog("查询sql="+sql);
rs.execute(sql);
if (rs.next()){
String num = rs.getString("sl");
writeLog("num="+num);
BigDecimal bigDecimal = new BigDecimal(num);
BigDecimal nowNum = bigDecimal.add(new BigDecimal(modoNum));
sql = "update uf_wzdbptbz set sl ='"+nowNum+"' where id='"+modeId+"'";
rs1.execute(sql);
}else{
result.put("message", "获取调拨数量异常");
out.print(result.toJSONString());
return;
}
}
}
result.put("code", 0);
result.put("message", "退回 更新数量成功");
out.print(result.toJSONString());
%>
<%!
private void writeLog(Object o) {
Log var3 = LogFactory.getLog(this.getClass().getName());
if(o instanceof Exception) {
var3.info(this.getClass().getName(), (Exception)o);
} else {
var3.info(o);
}
}
/**
* 组装完整对象
* @param columnNames
* @param array
* @return
*/
public JSONObject getCompleteObject(String[] columnNames,JSONArray array){
JSONObject object = new JSONObject();
for (int j=0;j<array.size();j++){
object.put(columnNames[j],array.get(j));
}
return object;
}
private String getGDZCKPH(String id) {
if (id.equals("")) {
return "";
}
RecordSetDataSource rsds = new RecordSetDataSource("HERP");
String sql;
sql = "select GDZCKPH from UF_GDZCB where id=" + id;
rsds.execute(sql);
rsds.next();
return Util.null2String(rsds.getString("GDZCKPH"));
}
private String getLastName(String id) {
RecordSet rs = new RecordSet();
String sql;
sql = "select lastname from hrmresource where id=" + id;
rs.execute(sql);
rs.next();
return Util.null2String(rs.getString(1));
}
private byte[] readInputStream(InputStream inStream) throws Exception {
ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
boolean var3 = false;
int len;
while((len = inStream.read(buffer)) != -1) {
outSteam.write(buffer, 0, len);
}
outSteam.close();
inStream.close();
return outSteam.toByteArray();
}
%>