package com.slcf.controller;
|
|
import java.io.BufferedReader;
|
import java.io.IOException;
|
import java.io.InputStreamReader;
|
import java.io.OutputStream;
|
import java.io.UnsupportedEncodingException;
|
import java.net.HttpURLConnection;
|
import java.net.MalformedURLException;
|
import java.net.URL;
|
import java.net.URLConnection;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
import com.slcf.pojo.*;
|
import com.slcf.service.*;
|
import org.apache.log4j.Logger;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.slcf.erp.ErpBean;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
import sun.misc.BASE64Encoder;
|
|
@Controller
|
@RequestMapping("/asrsApi")
|
public class AsrsController {
|
|
@Resource
|
WaitPakInService waitPakInService;
|
@Autowired
|
WaitPakOutService waitPakOutService;
|
@Autowired
|
WaitCheckService waitCheckService;
|
@Autowired
|
LocationService locationService;
|
@Autowired
|
LocDetailService locDetailService;
|
@Autowired
|
MatCodeService matCodeService;
|
@Autowired
|
WorkFileService workFileService;
|
|
Logger logger=Logger.getLogger(AsrsController.class);
|
|
/**
|
* 上架接口
|
* @param requestBody
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
// @RequestMapping("/waitPakIn.action")
|
@RequestMapping(value="/waitPakIn.action",method={ RequestMethod.GET, RequestMethod.POST })
|
// public String getWaitPakIn(@RequestParam("param")String param,HttpServletRequest request){
|
public JSONObject getWaitPakIn(@RequestBody String requestBody,HttpServletRequest request){
|
// public JSONObject getWaitPakIn(HttpServletRequest request){
|
// String result = "";
|
logger.error("SAP Store Interface Data-----" + requestBody);
|
JSONObject map = new JSONObject();
|
String zpallet = "";
|
String lgnum="0",zmatid="0";
|
int tbnum=0,tbpos=0;
|
// String param = "{bdatu: \"日期bdatu1\",bzeit: \"bzeit2\",TrHeadToItem: [{lgnum: \"1\",tbnum: \"测试1\"},{lgnum: \"2\",tbnum: \"2\"}]}";
|
try {
|
// System.out.println("requestBodyrequestBody@11-----" + requestBody);
|
// logger.info("requestBodyrequestBody@11-----" + requestBody);
|
JSONObject json = JSONObject.fromObject(requestBody);
|
// logger.info("requestBodyrequestBody@22-----" + requestBody);
|
//JSONArray json = JSONArray.fromObject(param);
|
// JSONObject job = json.getJSONObject(0);
|
// String bdatu = json.get("bdatu").toString();
|
// String bzeit = json.get("bzeit").toString();
|
String TrHeadToItem = json.get("item").toString();
|
JSONArray jsonArray = JSONArray.fromObject(TrHeadToItem);
|
JSONArray arrRet = new JSONArray();
|
if(jsonArray.size()>0) {
|
for(int i=0;i<jsonArray.size();i++){
|
JSONObject jsonRet = new JSONObject();
|
// ErpBean erp = new ErpBean();
|
WaitPakInBean waitPakIn = new WaitPakInBean();
|
JSONObject job = jsonArray.getJSONObject(i);
|
waitPakIn.setLgnum(job.get("lgnum").toString());
|
waitPakIn.setTbnum(job.get("tbnum").toString().equals("")?0:Integer.parseInt(job.get("tbnum").toString()));
|
waitPakIn.setTbpos(job.get("tbpos").toString().equals("")?0:Integer.parseInt(job.get("tbpos").toString()));
|
waitPakIn.setZmatid(job.get("zmatid").toString());
|
|
lgnum = job.get("lgnum").toString();
|
tbnum = job.get("tbnum").toString().equals("")?0:Integer.parseInt(job.get("tbnum").toString());
|
tbpos = job.get("tbpos").toString().equals("")?0:Integer.parseInt(job.get("tbpos").toString());
|
zmatid = job.get("zmatid").toString();
|
|
// if(job.has("matnr")) {
|
waitPakIn.setMatnr(job.get("matnr").toString());
|
// }else {
|
// waitPakIn.setMatnr("");
|
// }
|
if(job.has("maktx")) {
|
String maktx = java.net.URLDecoder.decode(job.get("maktx").toString(), "utf-8");
|
waitPakIn.setMaktx(maktx);
|
}else {
|
waitPakIn.setMaktx("");
|
}
|
if(job.has("werks")) {
|
waitPakIn.setWerks(job.get("werks").toString());
|
}else {
|
waitPakIn.setWerks("");
|
}
|
if(job.has("anfme")) {
|
waitPakIn.setAnfme(job.get("anfme").toString().equals("")?0:Double.parseDouble(job.get("anfme").toString()));
|
}else {
|
waitPakIn.setAnfme(0);
|
}
|
if(job.has("altme")) {
|
waitPakIn.setAltme(job.get("altme").toString());
|
}else {
|
waitPakIn.setAltme("");
|
}
|
if(job.has("zpallet")) {
|
zpallet = job.get("zpallet").toString();
|
}else {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tbnum", job.get("tbnum").toString());
|
jsonRet.put("tbpos", job.get("tbpos").toString());
|
jsonRet.put("zmatid", job.get("zmatid").toString());
|
arrRet.add(jsonRet);
|
map.put("item", arrRet);
|
map.put("zstatus", "E");
|
map.put("message", "上架指令接收失败,托盘号不存在");
|
return map;
|
}
|
waitPakIn.setZpallet(zpallet);
|
if(job.has("bname")) {
|
waitPakIn.setBname(job.get("bname").toString());
|
waitPakIn.setModi_user(job.get("bname").toString());
|
}else {
|
waitPakIn.setBname("");
|
waitPakIn.setModi_user("");
|
}
|
int result = waitPakInService.insertWaitPakIn(waitPakIn);
|
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tbnum", job.get("tbnum").toString());
|
jsonRet.put("tbpos", job.get("tbpos").toString());
|
jsonRet.put("zmatid", job.get("zmatid").toString());
|
arrRet.add(jsonRet);
|
// String str = job.get("lgnum").toString() + "@@" + job.get("tbnum").toString();
|
// System.out.println(str);
|
}
|
}
|
map.put("item", arrRet);
|
map.put("zstatus", "S");
|
map.put("message", "上架指令接收成功");
|
// System.out.println(TrHeadToItem);
|
}catch (Exception e) {
|
JSONArray arrRet = new JSONArray();
|
JSONObject jsonRet = new JSONObject();
|
jsonRet.put("lgnum", lgnum+"");
|
jsonRet.put("tbnum", tbnum+"");
|
jsonRet.put("tbpos", tbpos);
|
jsonRet.put("zmatid", zmatid);
|
arrRet.add(jsonRet);
|
map.put("item", arrRet);
|
map.put("zstatus", "E");
|
map.put("message", "上架指令接收失败" + e.getMessage() + "json:" + requestBody);
|
if(!zpallet.equals("")) {
|
int result = waitPakInService.delWaitPakInByZpallet(zpallet);
|
}
|
// System.out.println(e.getMessage());
|
logger.error("SAP Store Interface Error-----" + e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 上架数据取消接口
|
* @param requestBody
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value="/cancelWaitPakIn.action",method={ RequestMethod.GET, RequestMethod.POST })
|
public JSONObject getCancelWaitPakIn(@RequestBody String requestBody,HttpServletRequest request){
|
logger.error("SAP Cancel Store Interface Data-----" + requestBody);
|
JSONObject map = new JSONObject();
|
// String param = "{bdatu: \"日期bdatu1\",bzeit: \"bzeit2\",TrHeadToItem: [{lgnum: \"1\",tbnum: \"测试1\"},{lgnum: \"2\",tbnum: \"2\"}]}";
|
String lgnum="0",zmatid="0";
|
int tbnum=0,tbpos=0;
|
try {
|
// System.out.println("requestBodyrequestBody@11-----" + requestBody);
|
// logger.info("requestBodyrequestBody@11-----" + requestBody);
|
JSONObject json = JSONObject.fromObject(requestBody);
|
// logger.info("requestBodyrequestBody@22-----" + requestBody);
|
String TrHeadToItem = json.get("item").toString();
|
JSONArray jsonArray = JSONArray.fromObject(TrHeadToItem);
|
JSONArray arrRet = new JSONArray();
|
if(jsonArray.size()>0) {
|
for(int i=0;i<jsonArray.size();i++){
|
JSONObject jsonRet = new JSONObject();
|
// ErpBean erp = new ErpBean();
|
WaitPakInBean waitPakIn = new WaitPakInBean();
|
JSONObject job = jsonArray.getJSONObject(i);
|
waitPakIn.setLgnum(job.get("lgnum").toString());
|
waitPakIn.setTbnum(job.get("tbnum").toString().equals("")?0:Integer.parseInt(job.get("tbnum").toString()));
|
waitPakIn.setTbpos(job.get("tbpos").toString().equals("")?0:Integer.parseInt(job.get("tbpos").toString()));
|
waitPakIn.setZmatid(job.get("zmatid").toString());
|
|
lgnum = job.get("lgnum").toString();
|
tbnum = job.get("tbnum").toString().equals("")?0:Integer.parseInt(job.get("tbnum").toString());
|
tbpos = job.get("tbpos").toString().equals("")?0:Integer.parseInt(job.get("tbpos").toString());
|
zmatid = job.get("zmatid").toString();
|
|
// waitPakIn.setMatnr(job.get("matnr").toString());
|
// String maktx = java.net.URLDecoder.decode(job.get("maktx").toString(), "utf-8");
|
// waitPakIn.setMaktx(maktx);
|
// waitPakIn.setWerks(job.get("werks").toString());
|
// waitPakIn.setAnfme(job.get("anfme").toString().equals("")?0:Double.parseDouble(job.get("anfme").toString()));
|
// waitPakIn.setAltme(job.get("altme").toString());
|
// waitPakIn.setZpallet(job.get("zpallet").toString());
|
// waitPakIn.setBname(job.get("bname").toString());
|
// waitPakIn.setModi_user(job.get("bname").toString());
|
WaitPakInBean waitPakInBean = waitPakInService.queryWaitPakInById(waitPakIn);
|
if(waitPakInBean!=null) {
|
if(waitPakInBean.getStatus().equals("Y")) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tbnum", job.get("tbnum").toString());
|
jsonRet.put("tbpos", job.get("tbpos").toString());
|
jsonRet.put("zmatid", job.get("zmatid").toString());
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "取消上架指令失败,货物入库中");
|
arrRet.add(jsonRet);
|
continue;
|
// map.put("item", arrRet);
|
// return map;
|
}
|
int result = waitPakInService.delWaitPakIn(waitPakIn);
|
if(result<0) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tbnum", job.get("tbnum").toString());
|
jsonRet.put("tbpos", job.get("tbpos").toString());
|
jsonRet.put("zmatid", job.get("zmatid").toString());
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "取消上架指令失败,数据不存在");
|
arrRet.add(jsonRet);
|
// map.put("item", arrRet);
|
// return map;
|
}
|
else {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tbnum", job.get("tbnum").toString());
|
jsonRet.put("tbpos", job.get("tbpos").toString());
|
jsonRet.put("zmatid", job.get("zmatid").toString());
|
jsonRet.put("zstatus", "S");
|
jsonRet.put("message", "取消上架指令成功");
|
arrRet.add(jsonRet);
|
logger.error("SAP Cancel Store Interface Success-----" + jsonRet.toString());
|
}
|
}
|
else {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tbnum", job.get("tbnum").toString());
|
jsonRet.put("tbpos", job.get("tbpos").toString());
|
jsonRet.put("zmatid", job.get("zmatid").toString());
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "取消上架指令失败,数据不存在");
|
arrRet.add(jsonRet);
|
// map.put("item", arrRet);
|
// return map;
|
}
|
// String str = job.get("lgnum").toString() + "@@" + job.get("tbnum").toString();
|
// System.out.println(str);
|
}
|
}
|
map.put("item", arrRet);
|
// map.put("zstatus", "S");
|
// map.put("message", "取消上架指令成功");
|
// System.out.println(TrHeadToItem);
|
}catch (Exception e) {
|
JSONArray arrRet = new JSONArray();
|
JSONObject jsonRet = new JSONObject();
|
jsonRet.put("lgnum", lgnum+"");
|
jsonRet.put("tbnum", tbnum+"");
|
jsonRet.put("tbpos", tbpos);
|
jsonRet.put("zmatid", zmatid);
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "取消上架指令失败" + e.getMessage());
|
arrRet.add(jsonRet);
|
map.put("item", arrRet);
|
// System.out.println(e.getMessage());
|
logger.error("SAP Cancel Store Interface Error-----" + e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 下架测试接口
|
* @param requestBody
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value="/waitPakOut1.action",method={ RequestMethod.GET, RequestMethod.POST })
|
public JSONObject getWaitPakOut1(@RequestBody String requestBody,HttpServletRequest request){
|
JSONObject map = new JSONObject();
|
logger.error("SAP Retrieve Interface Data-----" + requestBody);
|
try {
|
JSONObject json = JSONObject.fromObject(requestBody);
|
String TrHeadToItem = json.get("item").toString();
|
JSONArray jsonArray = JSONArray.fromObject(TrHeadToItem);
|
JSONArray arrRet = new JSONArray();
|
if(jsonArray.size()>0) {
|
for(int i=0;i<jsonArray.size();i++){
|
JSONObject job = jsonArray.getJSONObject(i);
|
String sloc_no=job.get("vlpla").toString();
|
LocationBean locBean = locationService.queryLocationById(sloc_no);
|
if(locBean==null || !locBean.getLoc_sts().equals("F")) {
|
map.put("item", "");
|
map.put("zstatus", "E");
|
map.put("message", "下架指令接收失败,源库位非在库状态--" + sloc_no);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败,源库位非在库状态" + sloc_no);
|
return map;
|
}
|
String matnr = java.net.URLDecoder.decode(job.get("matnr").toString(), "utf-8");
|
// String matnr = job.get("matnr").toString();
|
double vsolm = job.get("vsolm").toString().equals("")?0:Double.parseDouble(job.get("vsolm").toString());
|
LocDetailBean locDetailBean = locDetailService.queryLocDetailById(sloc_no,matnr);
|
if(locDetailBean==null && locDetailBean.getAnfme()<vsolm) {
|
map.put("item", "");
|
map.put("zstatus", "E");
|
map.put("message", "下架指令接收失败," + sloc_no + "库存明细不存在或小于下架数量--" + vsolm);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败" + sloc_no + "库存明细不存在或小于下架数量--" + vsolm);
|
return map;
|
}
|
String nltyp=job.get("vlpla").toString();
|
String dloc_no=job.get("nlpla").toString();
|
if(nltyp.equals("A01") && dloc_no!=null && !dloc_no.equals("")) {
|
LocationBean dlocBean = locationService.queryLocationById(dloc_no);
|
if(dlocBean==null || !dlocBean.equals("F") || !dlocBean.equals("O")) {
|
map.put("item", "");
|
map.put("zstatus", "E");
|
map.put("message", "下架指令接收失败,目标库位非在库或空状态--" + dloc_no);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败,目标库位非在库或空状态--" + dloc_no);
|
return map;
|
}
|
}
|
int crns = (Integer.parseInt(sloc_no.substring(0,1)) + 1)/2;
|
int crnd = (Integer.parseInt(dloc_no.substring(0,1)) + 1)/2;
|
if(crns != crnd) {
|
map.put("item", "");
|
map.put("zstatus", "E");
|
map.put("message", "下架指令接收失败,源库位" + sloc_no + "与目标库位" + dloc_no + "不在同一巷道");
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败,源库位" + sloc_no + "与目标库位" + dloc_no + "不在同一巷道");
|
return map;
|
}
|
|
}
|
for(int i=0;i<jsonArray.size();i++){
|
JSONObject jsonRet = new JSONObject();
|
WaitPakOutBean waitPakOut = new WaitPakOutBean();
|
JSONObject job = jsonArray.getJSONObject(i);
|
waitPakOut.setLgnum(job.get("lgnum").toString());
|
waitPakOut.setTanum(job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
waitPakOut.setTapos(job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
// waitPakOut.setZmatid(job.get("zmatid").toString());
|
waitPakOut.setMatnr(job.get("matnr").toString());
|
String maktx = java.net.URLDecoder.decode(job.get("maktx").toString(), "utf-8");
|
waitPakOut.setMaktx(maktx);
|
waitPakOut.setWerks(job.get("werks").toString());
|
waitPakOut.setVsolm(job.get("vsolm").toString().equals("")?0:Double.parseDouble(job.get("vsolm").toString()));
|
waitPakOut.setMeins(job.get("meins").toString());
|
waitPakOut.setVltyp(job.get("vltyp").toString());
|
waitPakOut.setVlpla(job.get("vlpla").toString());
|
waitPakOut.setNltyp(job.get("nltyp").toString());
|
waitPakOut.setNlpla(job.get("nlpla").toString());
|
// waitPakOut.setZpallet(job.get("zpallet").toString());
|
waitPakOut.setBname(job.get("bname").toString());
|
waitPakOut.setModi_user(job.get("bname").toString());
|
|
int result = waitPakOutService.insertWaitPakOut(waitPakOut);
|
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString());
|
jsonRet.put("tapos", job.get("tapos").toString());
|
// jsonRet.put("zmatid", job.get("zmatid").toString());
|
arrRet.add(jsonRet);
|
// String str = job.get("lgnum").toString() + "@@" + job.get("tbnum").toString();
|
// System.out.println(str);
|
}
|
}
|
map.put("item", arrRet);
|
map.put("zstatus", "S");
|
map.put("message", "下架指令接收成功");
|
// System.out.println(TrHeadToItem);
|
}catch (Exception e) {
|
map.put("item", "");
|
map.put("zstatus", "E");
|
map.put("message", "下架指令接收失败" + e.getMessage());
|
// System.out.println(e.getMessage());
|
logger.error("SAP Retrieve Interface Error-----" + e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 下架正式接口
|
* @param requestBody
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value="/waitPakOut.action",method={ RequestMethod.GET, RequestMethod.POST })
|
public synchronized JSONObject getWaitPakOut(@RequestBody String requestBody,HttpServletRequest request){
|
JSONObject map = new JSONObject();
|
logger.error("SAP Retrieve Interface Data22-----" + requestBody);
|
String lgnum="0";
|
int tanum=0,tapos=0;
|
try {
|
JSONObject json = JSONObject.fromObject(requestBody);
|
String TrHeadToItem = json.get("item").toString();
|
JSONArray jsonArray = JSONArray.fromObject(TrHeadToItem);
|
JSONArray arrRet = new JSONArray();
|
if(jsonArray.size()>0) {
|
for(int i=0;i<jsonArray.size();i++){
|
JSONObject jsonRet = new JSONObject();
|
JSONObject job = jsonArray.getJSONObject(i);
|
|
String sloc_no=job.get("vlpla").toString();
|
String matnr = job.get("matnr").toString();
|
double vsolm = job.get("vsolm").toString().equals("")?0:Double.parseDouble(job.get("vsolm").toString());
|
String bwlvs=job.get("bwlvs").toString();
|
if(bwlvs.equals("711") || bwlvs.equals("712")) { //库存盘盈(712)盘亏(711)
|
if(bwlvs.equals("712")) {
|
sloc_no=job.get("nlpla").toString();
|
}
|
LocDetailBean locDetl = locDetailService.queryLocDetailById(sloc_no, matnr);
|
int result = 0;
|
if(locDetl!=null) {//库存存在,更新库存
|
if(bwlvs.equals("712")){
|
locDetl.setAnfme(locDetl.getAnfme() + vsolm);
|
}else if(bwlvs.equals("711")) {
|
locDetl.setAnfme(locDetl.getAnfme() - vsolm);
|
}
|
result = locDetailService.upLocDetail(locDetl);
|
}else {
|
if(bwlvs.equals("712")){ //库存没有,且盘盈状态
|
locDetl = new LocDetailBean();
|
locDetl.setLoc_no(sloc_no);
|
locDetl.setLgnum(job.get("lgnum").toString());
|
locDetl.setTbnum(job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
locDetl.setTbpos(job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
locDetl.setMaktx(java.net.URLDecoder.decode(job.get("maktx").toString(), "utf-8"));
|
locDetl.setWerks(job.get("werks").toString());
|
locDetl.setAnfme(vsolm);
|
locDetl.setAltme(job.get("meins").toString());
|
locDetl.setBname(job.get("bname").toString());
|
result = locDetailService.insertLocDetail(locDetl);
|
}else {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "盘点调整失败,库存为空无法执行盘亏--" + sloc_no + "--" + matnr);
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----盘点调整失败,库存为空无法执行盘亏--" + sloc_no + "--" + matnr);
|
continue;
|
}
|
}
|
if(result>0) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "S");
|
jsonRet.put("message", "盘点调整成功--" + sloc_no + "--" + matnr);
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Check Interface-----盘点调整成功--" + sloc_no + "--" + matnr);
|
}else {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "盘点调整失败--" + sloc_no + "--" + matnr);
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----盘点调整失败2--" + sloc_no + "--" + matnr);
|
}
|
}else {
|
LocationBean locBean = locationService.queryLocationById(sloc_no);
|
if(locBean==null || !locBean.getLoc_sts().equals("F")) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "下架指令接收失败,源库位非在库状态--" + sloc_no);
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败,源库位非在库状态" + sloc_no);
|
continue;
|
}
|
|
//String matnr = job.get("matnr").toString();
|
LocDetailBean locDetailBean = locDetailService.queryLocDetailById(sloc_no,matnr);
|
// if(locDetailBean==null || locDetailBean.getAnfme()<vsolm) {
|
if(locDetailBean==null) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
// jsonRet.put("message", "下架指令接收失败," + sloc_no + "库存明细不存在或小于下架数量--" + vsolm);
|
jsonRet.put("message", "下架指令接收失败," + sloc_no + "库存不存在");
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败" + sloc_no + "库存不存在--");
|
continue;
|
}else if(locDetailBean.getAnfme()<vsolm) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "下架指令接收失败," + sloc_no + "库存数量小于下架数量--" + vsolm);
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败" + sloc_no + "库存数量小于下架数量--" + vsolm);
|
continue;
|
}
|
// (库存数量-出库通知档数量) < 下架数量
|
List<WaitPakOutBean> waitPakOutBeanList = waitPakOutService.queryWaitOutPak(locDetailBean.getLoc_no(), locDetailBean.getMatnr());
|
if (waitPakOutBeanList.size() > 0) {
|
Double realAnfme = new Double(locDetailBean.getAnfme() - waitPakOutBeanList.get(0).getVsolm());
|
if (realAnfme < vsolm) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "下架指令接收失败," + sloc_no + "库存数量小于下架数量--" + vsolm);
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败" + sloc_no + "库存数量小于下架数量--" + vsolm);
|
continue;
|
}
|
}
|
String nltyp=job.get("vlpla").toString();
|
String dloc_no=job.get("nlpla").toString();
|
if(nltyp.equals("A01") && dloc_no!=null && !dloc_no.equals("")) {
|
LocationBean dlocBean = locationService.queryLocationById(dloc_no);
|
if(dlocBean==null || !dlocBean.equals("F") || !dlocBean.equals("O")) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "下架指令接收失败,目标库位非在库或空状态--" + dloc_no);
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败,目标库位非在库或空状态--" + dloc_no);
|
continue;
|
}
|
int crns = (Integer.parseInt(sloc_no.substring(0,1)) + 1)/2;
|
int crnd = (Integer.parseInt(dloc_no.substring(0,1)) + 1)/2;
|
if(crns != crnd) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
jsonRet.put("tapos", job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "下架指令接收失败,源库位" + sloc_no + "与目标库位" + dloc_no + "不在同一巷道");
|
arrRet.add(jsonRet);
|
logger.error("SAP Retrieve Interface Error-----下架指令接收失败,源库位" + sloc_no + "与目标库位" + dloc_no + "不在同一巷道");
|
continue;
|
}
|
}
|
|
WaitPakOutBean waitPakOut = new WaitPakOutBean();
|
// JSONObject job = jsonArray.getJSONObject(i);
|
waitPakOut.setLgnum(job.get("lgnum").toString());
|
waitPakOut.setTanum(job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString()));
|
waitPakOut.setTapos(job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString()));
|
// waitPakOut.setZmatid(job.get("zmatid").toString());
|
|
lgnum = job.get("lgnum").toString();
|
tanum = job.get("tanum").toString().equals("")?0:Integer.parseInt(job.get("tanum").toString());
|
tapos = job.get("tapos").toString().equals("")?0:Integer.parseInt(job.get("tapos").toString());
|
|
waitPakOut.setMatnr(job.get("matnr").toString());
|
// waitPakOut.setMaktx(job.get("maktx").toString());
|
if(job.has("maktx")) {
|
String maktx = java.net.URLDecoder.decode(job.get("maktx").toString(), "utf-8");
|
waitPakOut.setMaktx(maktx);
|
}else {
|
waitPakOut.setMaktx("");
|
}
|
if(job.has("werks")) {
|
waitPakOut.setWerks(job.get("werks").toString());
|
}else {
|
waitPakOut.setWerks("");
|
}
|
waitPakOut.setVsolm(job.get("vsolm").toString().equals("")?0:Double.parseDouble(job.get("vsolm").toString()));
|
if(job.has("meins")) {
|
waitPakOut.setMeins(job.get("meins").toString());
|
}else {
|
waitPakOut.setMeins("");
|
}
|
waitPakOut.setVltyp(job.get("vltyp").toString());
|
waitPakOut.setVlpla(job.get("vlpla").toString());
|
waitPakOut.setNltyp(job.get("nltyp").toString());
|
waitPakOut.setNlpla(job.get("nlpla").toString());
|
// waitPakOut.setZpallet(job.get("zpallet").toString());
|
if(job.has("bname")) {
|
waitPakOut.setBname(job.get("bname").toString());
|
waitPakOut.setModi_user(job.get("bname").toString());
|
}else {
|
waitPakOut.setBname("");
|
waitPakOut.setModi_user("");
|
}
|
int result = waitPakOutService.insertWaitPakOut(waitPakOut);
|
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("tanum", job.get("tanum").toString());
|
jsonRet.put("tapos", job.get("tapos").toString());
|
jsonRet.put("zstatus", "S");
|
jsonRet.put("message", "下架指令接收成功");
|
arrRet.add(jsonRet);
|
// String str = job.get("lgnum").toString() + "@@" + job.get("tbnum").toString();
|
// System.out.println(str);
|
}
|
}
|
}
|
map.put("item", arrRet);
|
// map.put("zstatus", "S");
|
// map.put("message", "下架指令接收成功");
|
// System.out.println(TrHeadToItem);
|
}catch (Exception e) {
|
JSONArray arrRet = new JSONArray();
|
JSONObject jsonRet = new JSONObject();
|
jsonRet.put("lgnum", lgnum);
|
jsonRet.put("tanum", tanum+"");
|
jsonRet.put("tapos", tapos+"");
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "下架指令接收失败" + e.getMessage());
|
arrRet.add(jsonRet);
|
map.put("item", arrRet);
|
// System.out.println(e.getMessage());
|
logger.error("SAP Retrieve Interface Error-----" + e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 盘点接口
|
* @param requestBody
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value="/locationCheck.action",method={ RequestMethod.GET, RequestMethod.POST })
|
public JSONObject locationCheck(@RequestBody String requestBody,HttpServletRequest request){
|
JSONObject map = new JSONObject();
|
logger.error("SAP Check Interface Data-----" + requestBody);
|
String lgnum="0",lqnum="0";
|
int ivnum=0,ivpos=0;
|
try {
|
JSONObject json = JSONObject.fromObject(requestBody);
|
String TrHeadToItem = json.get("item").toString();
|
JSONArray jsonArray = JSONArray.fromObject(TrHeadToItem);
|
JSONArray arrRet = new JSONArray();
|
if(jsonArray.size()>0) {
|
for(int i=0;i<jsonArray.size();i++){
|
JSONObject jsonRet = new JSONObject();
|
JSONObject job = jsonArray.getJSONObject(i);
|
|
String loc_no=job.get("lgpla").toString();
|
LocationBean locBean = locationService.queryLocationById(loc_no);
|
WaitCheckBean waitCheckBean = waitCheckService.getWaitCheckByLoc(loc_no);
|
if(locBean==null || (!locBean.getLoc_sts().equals("F") && null == waitCheckBean)) {
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("ivnum", job.get("ivnum").toString());
|
jsonRet.put("ivpos", job.get("ivpos").toString());
|
jsonRet.put("lqnum", job.get("lqnum").toString());
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "盘点指令接收失败,库位非在库状态--" + loc_no);
|
arrRet.add(jsonRet);
|
logger.error("SAP Check Interface Error-----盘点指令接收失败,库位非在库状态--" + loc_no);
|
continue;
|
}
|
|
WaitCheckBean waitCheck = new WaitCheckBean();
|
waitCheck.setLgnum(job.get("lgnum").toString());
|
waitCheck.setIvnum(job.get("ivnum").toString().equals("")?0:Integer.parseInt(job.get("ivnum").toString()));
|
waitCheck.setIvpos(job.get("ivpos").toString().equals("")?0:Integer.parseInt(job.get("ivpos").toString()));
|
waitCheck.setLqnum(job.get("lqnum").toString());
|
|
lgnum = job.get("lgnum").toString();
|
ivnum = job.get("ivnum").toString().equals("")?0:Integer.parseInt(job.get("ivnum").toString());
|
ivpos = job.get("ivpos").toString().equals("")?0:Integer.parseInt(job.get("ivpos").toString());
|
lqnum = job.get("lqnum").toString();
|
|
if(job.has("matnr")){
|
// String matnr = java.net.URLDecoder.decode(job.get("matnr").toString(), "utf-8");
|
waitCheck.setMatnr(job.get("matnr").toString());
|
}
|
// waitCheck.setMaktx(job.get("maktx").toString());
|
waitCheck.setWerks(job.get("werks").toString());
|
|
waitCheck.setLgtyp(job.get("lgtyp").toString());
|
waitCheck.setLgpla(job.get("lgpla").toString());
|
|
if(job.has("bname")) {
|
waitCheck.setModi_user(job.get("bname").toString());
|
}
|
// if(null == waitCheckBean) {
|
int result = waitCheckService.insertWaitCheck(waitCheck);
|
// }
|
|
jsonRet.put("lgnum", job.get("lgnum").toString());
|
jsonRet.put("ivnum", job.get("ivnum").toString());
|
jsonRet.put("ivpos", job.get("ivpos").toString());
|
jsonRet.put("lqnum", job.get("lqnum").toString());
|
jsonRet.put("zstatus", "S");
|
jsonRet.put("message", "盘点指令接收成功");
|
arrRet.add(jsonRet);
|
// System.out.println(str);
|
}
|
}
|
map.put("item", arrRet);
|
logger.error("SAP Check Interface Return Data-----" + arrRet.toString());
|
// map.put("zstatus", "S");
|
// map.put("message", "盘点指令接收成功");
|
// System.out.println(TrHeadToItem);
|
}catch (Exception e) {
|
JSONArray arrRet = new JSONArray();
|
JSONObject jsonRet = new JSONObject();
|
jsonRet.put("lgnum", lgnum);
|
jsonRet.put("ivnum", ivnum+"");
|
jsonRet.put("ivpos", ivpos+"");
|
jsonRet.put("lqnum", lqnum);
|
jsonRet.put("zstatus", "E");
|
jsonRet.put("message", "盘点指令接收失败" + e.getMessage());
|
arrRet.add(jsonRet);
|
map.put("item", arrRet);
|
// map.put("item", "");
|
// map.put("zstatus", "E");
|
// map.put("message", "盘点指令接收失败" + e.getMessage());
|
// System.out.println(e.getMessage());
|
logger.error("SAP Check Interface Error-----" + e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 库位信息返回接口
|
* @param requestBody
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value="/queryLocByBarcode.action",method={ RequestMethod.GET, RequestMethod.POST })
|
public JSONObject queryLocByBarcode(@RequestBody String requestBody,HttpServletRequest request){
|
JSONObject map = new JSONObject();
|
logger.error("SAP Response Location Data-----" + requestBody);
|
try {
|
JSONObject json = JSONObject.fromObject(requestBody);
|
String TrHeadToItem = json.get("item").toString();
|
JSONArray jsonArray = JSONArray.fromObject(TrHeadToItem);
|
JSONArray arrRet = new JSONArray();
|
if(jsonArray.size()>0) {
|
for(int i=0;i<jsonArray.size();i++){
|
JSONObject jsonRet = new JSONObject();
|
JSONObject job = jsonArray.getJSONObject(i);
|
|
String barcode = job.get("zpallet").toString();
|
String loc_no = "";
|
loc_no = locationService.queryLocationByBarcode(barcode);
|
|
jsonRet.put("zpallet", barcode);
|
jsonRet.put("lgpla", (loc_no==null || loc_no.equals(""))?"0":loc_no);
|
arrRet.add(jsonRet);
|
}
|
}
|
map.put("item", arrRet);
|
map.put("zstatus", "S");
|
map.put("message", "返回库位信息成功");
|
// System.out.println(TrHeadToItem);
|
}catch (Exception e) {
|
map.put("item", "");
|
map.put("zstatus", "E");
|
map.put("message", "返回库位信息失败" + e.getMessage());
|
// System.out.println(e.getMessage());
|
logger.error("SAP Response Location Error-----" + e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 库位信息返回接口
|
* @param requestBody
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value="/queryWrkDetl.action",method={ RequestMethod.GET, RequestMethod.POST })
|
public JSONObject queryWrkDetl(@RequestBody String requestBody,HttpServletRequest request){
|
|
JSONObject map = new JSONObject();
|
logger.info("工作明细返回接口调用:" + requestBody);
|
try {
|
JSONArray result = new JSONArray();
|
JSONObject json = JSONObject.fromObject(requestBody);
|
String zpallet = json.get("zpallet").toString();
|
|
List<WorkDetailBean> detls = workFileService.getWorkDetlList(zpallet);
|
for (WorkDetailBean detl : detls) {
|
WaitPakOutBean wrapper = new WaitPakOutBean();
|
wrapper.setLgnum(detl.getLgnum());
|
wrapper.setTanum(detl.getTbnum());
|
wrapper.setTapos(detl.getTbpos());
|
WaitPakOutBean waitPakout = waitPakOutService.queryWaitPakOutByNum(wrapper);
|
|
JSONObject detlJSON = new JSONObject();
|
detlJSON.put("LGNUM", detl.getLgnum());
|
detlJSON.put("TANUM", detl.getTbnum());
|
detlJSON.put("BDATU", detl.getModi_time());
|
detlJSON.put("BZEIT", detl.getModi_time());
|
detlJSON.put("TRART", "");
|
detlJSON.put("TAPOS", detl.getTbpos());
|
detlJSON.put("MATNR", detl.getMatnr());
|
detlJSON.put("MAKTX", detl.getMaktx());
|
detlJSON.put("WERKS", detl.getWerks());
|
detlJSON.put("LGORT", "");
|
detlJSON.put("MEINS", detl.getAltme());
|
detlJSON.put("VLTYP", waitPakout == null ? "" : waitPakout.getVltyp().toString());
|
detlJSON.put("NLTYP", waitPakout == null ? "" : waitPakout.getNltyp());
|
detlJSON.put("NLBER", "");
|
detlJSON.put("NLPLA", waitPakout == null ? "" : waitPakout.getNlpla());
|
detlJSON.put("VSOLM", detl.getAnfme());
|
detlJSON.put("BNAME", detl.getBname().toString());
|
result.add(detlJSON);
|
}
|
if (result.size() == 0){
|
map.put("item", result);
|
map.put("zstatus", "E");
|
map.put("message", "查询不到该托盘码的工作明细");
|
}else {
|
map.put("item", result);
|
map.put("zstatus", "S");
|
map.put("message", "返回明细信息成功");
|
}
|
|
}catch (Exception e){
|
map.put("item", "");
|
map.put("zstatus", "E");
|
map.put("message", "返回明细信息失败" + e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 入库完成,调用sap接口上传完成信息
|
*/
|
public static void sendPakInStatus(String httpUrl) {
|
// String token = getXCsrfToken(httpUrl);
|
String input = "ZHANGX:654321";
|
BASE64Encoder base = new BASE64Encoder();
|
String encodedPassword;
|
String token="";
|
String session_value="";
|
try {
|
encodedPassword = base.encode(input.getBytes("UTF-8"));
|
URL url1 = new URL(httpUrl);
|
HttpURLConnection connection1 = (HttpURLConnection) url1.openConnection();
|
connection1.setDoOutput(true);
|
connection1.setDoInput(true);
|
connection1.setRequestMethod("GET");
|
connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
|
connection1.setRequestProperty("x-csrf-token","Fetch");
|
String sessionCookie = connection1.getHeaderField("Set-Cookie");
|
String[] sessionId = sessionCookie.split(";");
|
session_value = sessionId[0];
|
token = connection1.getHeaderField("x-csrf-token");
|
// Map<String, List<String>> map = connection1.getHeaderFields();
|
// token = map.get("x-csrf-token").toString();
|
} catch (Exception e1) {
|
e1.printStackTrace();
|
}
|
|
try {
|
JSONObject jsObj = new JSONObject();
|
JSONArray arr = new JSONArray();
|
for(int i=0;i<2;i++) {
|
JSONObject json = new JSONObject();
|
json.put("lgnum","385");
|
long tbnum = 1000000046+i*8;
|
json.put("tbnum",Long.toString(tbnum));
|
json.put("tbpos",Integer.toString(i+1));
|
json.put("zmatid","20191124922");
|
int anfme=0;
|
if(i==0) {
|
anfme = 2;
|
}else {
|
anfme = 1;
|
}
|
json.put("anfme",Integer.toString(anfme));
|
json.put("altme","KG");
|
json.put("nltyp","A01");
|
json.put("nlber","001");
|
json.put("nlpla","0104501");
|
// json.put("vltyp","1");
|
// json.put("vlber","1");
|
// json.put("vlpla","1");
|
// json.put("zmatid","10021" + i);
|
arr.add(json);
|
}
|
// jsObj.put("lgnum","123");
|
// jsObj.put("tbnum","456");
|
jsObj.put("item", arr);
|
byte[] buff = jsObj.toString().getBytes();
|
int buffLen = buff.length;
|
//创建连接
|
try {
|
// String input = "ZHANGX:654321";
|
// BASE64Encoder base = new BASE64Encoder();
|
// String encodedPassword = base.encode(input.getBytes("UTF-8"));
|
|
URL url = new URL(httpUrl);
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
connection.setDoOutput(true);
|
connection.setDoInput(true);
|
connection.setRequestMethod("POST");
|
// connection.setUseCaches(false);
|
// connection.setInstanceFollowRedirects(true);
|
// connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
|
connection.setRequestProperty("Cookie", session_value);
|
connection.setRequestProperty("Content-Type","application/json");
|
connection.setRequestProperty("Accept","application/json");
|
connection.setRequestProperty("Content-Length","" + buffLen);
|
// connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
|
connection.setRequestProperty("x-csrf-token",token);
|
|
//POST请求
|
OutputStream out = connection.getOutputStream();
|
out.write(buff);
|
out.close();
|
|
//读取响应
|
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
connection.getInputStream()));
|
String lines;
|
StringBuffer sb = new StringBuffer("");
|
while ((lines = reader.readLine()) != null) {
|
lines = new String(lines.getBytes(), "utf-8");
|
sb.append(lines);
|
}
|
System.out.println(sb.toString());
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
}
|
|
/**
|
* 获取get返回的token
|
* @param urlStr
|
* @return
|
*/
|
public static String getXCsrfToken(String urlStr) {
|
String result = "";
|
try {
|
// String username = "zhangsan";
|
// String password = "mima";
|
String input = "ZHANGX:654321";
|
BASE64Encoder base = new BASE64Encoder();
|
String encodedPassword = base.encode(input.getBytes("UTF-8"));
|
|
URL url = new URL(urlStr);
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
connection.setDoOutput(true);
|
connection.setDoInput(true);
|
connection.setRequestMethod("GET");
|
connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
|
connection.setRequestProperty("x-csrf-token","Fetch");
|
Map<String, List<String>> map = connection.getHeaderFields();
|
// Map<String, List<String>> map2 = conn.getRequestProperties();
|
|
// System.out.println("显示响应Header信息...\n");
|
// for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
// System.out.println("Key : " + entry.getKey() +
|
// " ,Value : " + entry.getValue());
|
// }
|
// System.out.println("Content-Type---->"+map.get("Content-Type"));
|
System.out.println("x-csrf-token---->"+map.get("x-csrf-token"));
|
result = map.get("x-csrf-token").toString();
|
// System.out.println("\n使用key获得响应Header信息 \n");
|
// List<String> server = map.get("Server");
|
// if (server == null) {
|
// System.out.println("Key 'Server' is not found!");
|
// } else {
|
// for (String values : server) {
|
// System.out.println(values);
|
// }
|
// }
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return result;
|
}
|
|
public static void main(String[] args) {
|
try
|
{
|
String message1="%E8%A1%8C%E9%A1%B910000174610001%E4%B8%8D%E5%AD%98%E5%9C%A8%E6%88%96%E8%80%85%E4%B8%8E%E6%8B%A3%E9%85%8D%E6%97%A0%E5%85%B3";
|
message1 = java.net.URLDecoder.decode("%E8%A1%8C%E9%A1%B910000174610001%E4%B8%8D%E5%AD%98%E5%9C%A8%E6%88%96%E8%80%85%E4%B8%8E%E6%8B%A3%E9%85%8D%E6%97%A0%E5%85%B3", "utf-8");
|
|
String param = "{\"d\": {\"Item\": {\"results\": [{\"lgnum\": \"385\",\"zstatus\": \"s\",\"tbnum\": \"0000000011\",\"message\": \"aa转储请求 0000000011 不存在(请检查你的输入)\",\"tbpos\": \"0011\",\"zmatid\": \"231\"}]}}}";
|
JSONObject json = JSONObject.fromObject(param);
|
String d = json.get("d").toString();
|
JSONObject jsonD = JSONObject.fromObject(d);
|
String Item = jsonD.get("Item").toString();
|
JSONObject jsonItem = JSONObject.fromObject(Item);
|
String results = jsonItem.get("results").toString();
|
JSONArray array = JSONArray.fromObject(results);
|
|
if(array.size()>0) {
|
for(int i=0;i<array.size();i++){
|
JSONObject job = array.getJSONObject(i);
|
String zstatus = job.get("zstatus").toString();
|
String message = job.get("message").toString();
|
System.out.println("zstatus信息.." + zstatus);
|
System.out.println("message信息.." + message);
|
}
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
if(true) return;
|
// String httpUrl = "http://d01aas25.sap.kraussmaffeigroup.net:8025/sap/opu/odata/SAP/Z_WM_H5_SRV/TrHeadSet";
|
String httpUrl = "http://d01aas25.sap.kraussmaffeigroup.net:8025/sap/opu/odata/SAP/Z_WM_H5_SRV/AsrsTrSet";
|
sendPakInStatus(httpUrl);
|
if(true) return;
|
// getXCsrfToken("http://www.baidu.com");
|
// URLConnection conn;
|
// URL obj;
|
// try {
|
// obj = new URL("http://www.baidu.com");
|
// try {
|
// conn = obj.openConnection();
|
// Map<String, List<String>> map = conn.getHeaderFields();
|
// System.out.println("显示响应Header信息...\n");
|
//
|
//// for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
//// System.out.println("Key : " + entry.getKey() +
|
//// " ,Value : " + entry.getValue());
|
//// }
|
// System.out.println("Content-Type---->"+map.get("Content-Type"));
|
// } catch (IOException e) {
|
// // TODO Auto-generated catch block
|
// e.printStackTrace();
|
// }
|
// } catch (MalformedURLException e1) {
|
// // TODO Auto-generated catch block
|
// e1.printStackTrace();
|
// }
|
|
// byte[] buff = jsObj.toString().getBytes();
|
String content = "test";
|
byte[] buff = content.getBytes();
|
int buffLen = buff.length;
|
//创建连接
|
// String ADD_URL = "http://127.0.0.1:8080/asrs/asrsApi/waitPakIn.action";
|
String ADD_URL = "http://www.baidu.com";
|
try {
|
URL url = new URL(ADD_URL);
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
connection.setDoOutput(true);
|
connection.setDoInput(true);
|
connection.setRequestMethod("GET");
|
// connection.setUseCaches(false);
|
// connection.setInstanceFollowRedirects(true);
|
// connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
|
// connection.setRequestProperty("Content-Length","" + buffLen);
|
|
//POST请求
|
// OutputStream out = connection.getOutputStream();
|
// out.write(buff);
|
// out.close();
|
Map<String, List<String>> map = connection.getHeaderFields();
|
System.out.println("Content-Type---->"+map.get("Content-Type"));
|
//读取响应
|
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
connection.getInputStream()));
|
String lines;
|
StringBuffer sb = new StringBuffer("");
|
while ((lines = reader.readLine()) != null) {
|
lines = new String(lines.getBytes(), "utf-8");
|
sb.append(lines);
|
}
|
System.out.println(sb.toString());
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
// try {
|
// String param = "{bdatu: \"bdatu1\",bzeit: \"bzeit2\",TrHeadToItem: [{lgnum: \"1\",tbnum: \"1\"},{lgnum: \"2\",tbnum: \"2\"}]}";
|
// JSONObject json = JSONObject.fromObject(param);
|
// // JSONArray json = JSONArray.fromObject(param);
|
//// JSONObject job = json.getJSONObject(0);
|
// String bdatu = json.get("bdatu").toString();
|
// String TrHeadToItem = json.get("TrHeadToItem").toString();
|
// JSONArray jsonArray = JSONArray.fromObject(TrHeadToItem);
|
// if(jsonArray.size()>0) {
|
// for(int i=0;i<jsonArray.size();i++){
|
// JSONObject job = jsonArray.getJSONObject(i);
|
// String str = job.get("lgnum").toString() + "@@" + job.get("tbnum").toString();
|
// System.out.println(str);
|
// }
|
// }
|
//
|
//// System.out.println(TrHeadToItem);
|
// }catch (Exception e) {
|
// System.out.println(e.getMessage());
|
// }
|
}
|
}
|