diaoboSLReject.jsp 4.74 KB
<%--
  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();
    }
%>