Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						9686b9f9f3
					
				|  | @ -0,0 +1,161 @@ | ||||||
|  | package nc.bs.ic; | ||||||
|  | 
 | ||||||
|  | import com.alibaba.fastjson.JSONObject; | ||||||
|  | import nc.IHttpPostOtherSys; | ||||||
|  | import nc.hr.utils.PubEnv; | ||||||
|  | import nc.itf.scmpub.reference.uap.para.SysParaInitQuery; | ||||||
|  | import nc.pub.fa.common.util.StringUtils; | ||||||
|  | import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||||
|  | 
 | ||||||
|  | import java.io.BufferedReader; | ||||||
|  | import java.io.IOException; | ||||||
|  | import java.io.InputStreamReader; | ||||||
|  | import java.io.OutputStreamWriter; | ||||||
|  | import java.net.HttpURLConnection; | ||||||
|  | import java.net.URL; | ||||||
|  | import java.util.HashMap; | ||||||
|  | import java.util.List; | ||||||
|  | import java.util.Map; | ||||||
|  | 
 | ||||||
|  | public class HttpPostOtherSysImpl implements IHttpPostOtherSys { | ||||||
|  | 
 | ||||||
|  |     private static final String USER_ID = "BIP"; | ||||||
|  |     private static final String PASSWORD = "BIP@2025bip"; | ||||||
|  |     private static final String CLIENT_TYPE = "S"; | ||||||
|  |     private static final String EP_ID = ""; | ||||||
|  |     private static final String LOGIN_URL = "/GTHINKING/AjaxService/N_MISPRO/100208057.ashx/Login"; | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String callLE(String url, JSONObject json) { | ||||||
|  | //        String leip = SysParaInitQuery.getParaString(PubEnv.getPk_group(), "LEIP"); | ||||||
|  |         String mesip = "http://192.168.29.32"; | ||||||
|  |         String baseurl = mesip + url; | ||||||
|  |         String cookie = this.getMESToken(mesip); | ||||||
|  |         Map<String, String> headers = new HashMap<>(); | ||||||
|  |         headers.put("Set-Cookie", cookie); | ||||||
|  |         return doPost(baseurl, headers, json); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private String getMESToken(String leip) { | ||||||
|  |         JSONObject jsonObject = new JSONObject(); | ||||||
|  |         jsonObject.put("userId", USER_ID); | ||||||
|  |         jsonObject.put("password", PASSWORD); | ||||||
|  |         jsonObject.put("clientType", CLIENT_TYPE); | ||||||
|  |         jsonObject.put("epId", EP_ID); | ||||||
|  |         return postCookie(leip + LOGIN_URL, null, jsonObject); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 业务请求post方法 | ||||||
|  |      */ | ||||||
|  |     private String doPost(String baseurl, Map<String, String> map, JSONObject json) { | ||||||
|  |         BufferedReader reader = null; | ||||||
|  |         try { | ||||||
|  |             URL url = new URL(baseurl);// 创建连接 | ||||||
|  |             HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||||||
|  |             connection.setDoOutput(true); | ||||||
|  |             connection.setDoInput(true); | ||||||
|  |             connection.setUseCaches(false); | ||||||
|  |             connection.setInstanceFollowRedirects(true); | ||||||
|  |             connection.setRequestMethod("POST"); // 设置请求方式 | ||||||
|  |             // 设置接收数据的格式 | ||||||
|  |             connection.setRequestProperty("Content-Type", "application/json"); // 设置发送数据的格式 | ||||||
|  |             if (map != null) { | ||||||
|  |                 for (String key : map.keySet()) { | ||||||
|  |                     connection.setRequestProperty(key, map.get(key)); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             connection.connect(); | ||||||
|  |             // 一定要用BufferedReader 来接收响应, 使用字节来接收响应的方法是接收不到内容的 | ||||||
|  |             OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); // UTF-8编码 | ||||||
|  |             if (json != null) { | ||||||
|  |                 out.append(json.toString()); | ||||||
|  |             } | ||||||
|  |             out.flush(); | ||||||
|  |             out.close(); | ||||||
|  |             // 读取响应 | ||||||
|  |             reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); | ||||||
|  |             String line; | ||||||
|  |             String res = ""; | ||||||
|  |             while ((line = reader.readLine()) != null) { | ||||||
|  |                 res += line; | ||||||
|  |             } | ||||||
|  |             reader.close(); | ||||||
|  |             return res; | ||||||
|  |         } catch (Exception e) { | ||||||
|  | //            e.printStackTrace(); | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 获取cookie的请求post | ||||||
|  |      */ | ||||||
|  |     private String postCookie(String baseurl, Map<String, String> map, JSONObject json) { | ||||||
|  |         BufferedReader reader = null; | ||||||
|  |         try { | ||||||
|  |             URL url = new URL(baseurl); | ||||||
|  |             HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||||||
|  |             connection.setDoOutput(true); | ||||||
|  |             connection.setDoInput(true); | ||||||
|  |             connection.setUseCaches(false); | ||||||
|  |             connection.setInstanceFollowRedirects(true); | ||||||
|  |             connection.setRequestMethod("POST"); | ||||||
|  |             connection.setRequestProperty("Content-Type", "application/json"); | ||||||
|  | 
 | ||||||
|  |             if (map != null) { | ||||||
|  |                 for (String key : map.keySet()) { | ||||||
|  |                     connection.setRequestProperty(key, map.get(key)); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             connection.connect(); | ||||||
|  | 
 | ||||||
|  |             // 写入请求体 | ||||||
|  |             OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); | ||||||
|  |             if (json != null) { | ||||||
|  |                 out.append(json.toString()); | ||||||
|  |             } | ||||||
|  |             out.flush(); | ||||||
|  |             out.close(); | ||||||
|  | 
 | ||||||
|  |             // 读取响应头中的 Set-Cookie | ||||||
|  |             Map<String, List<String>> headers = connection.getHeaderFields(); | ||||||
|  |             String setCookieHeader = null; | ||||||
|  | 
 | ||||||
|  |             for (Map.Entry<String, List<String>> entry : headers.entrySet()) { | ||||||
|  |                 if ("Set-Cookie".equalsIgnoreCase(entry.getKey())) { | ||||||
|  |                     setCookieHeader = entry.getValue().get(0); // 取第一个 Set-Cookie 头 | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             if (setCookieHeader != null) { | ||||||
|  |                 return extractAspxAuth(setCookieHeader); // 返回 ASPXAUTH 的值 | ||||||
|  |             } else { | ||||||
|  |                 return null; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |         } catch (Exception e) { | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } finally { | ||||||
|  |             if (reader != null) { | ||||||
|  |                 try { | ||||||
|  |                     reader.close(); | ||||||
|  |                 } catch (IOException e) { | ||||||
|  |                     e.printStackTrace(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // 提取 .ASPXAUTH 的值 | ||||||
|  |     private String extractAspxAuth(String cookieHeader) { | ||||||
|  |         String[] cookies = cookieHeader.split("; "); | ||||||
|  |         for (String cookie : cookies) { | ||||||
|  |             if (cookie.startsWith(".ASPXAUTH=")) { | ||||||
|  |                 return cookie.substring(".ASPXAUTH=".length()); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,15 @@ | ||||||
|  | package nc; | ||||||
|  | 
 | ||||||
|  | import com.alibaba.fastjson.JSONObject; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public interface IHttpPostOtherSys { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      *  xuwjl@yonyou.com  2025年4月24日 15:24:14 | ||||||
|  |      * @param url LE的接口地址,不包含ip | ||||||
|  |      * @param json 入参 | ||||||
|  |      */ | ||||||
|  |     public String callLE(String url, JSONObject json); | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -7,6 +7,7 @@ import nc.bs.framework.common.InvocationInfoProxy; | ||||||
| import nc.bs.framework.common.NCLocator; | import nc.bs.framework.common.NCLocator; | ||||||
| import nc.itf.bd.defdoc.IDefdocService; | import nc.itf.bd.defdoc.IDefdocService; | ||||||
| import nc.itf.pim.project.prv.IProject; | import nc.itf.pim.project.prv.IProject; | ||||||
|  | import nc.jdbc.framework.SQLParameter; | ||||||
| import nc.jdbc.framework.processor.ColumnListProcessor; | import nc.jdbc.framework.processor.ColumnListProcessor; | ||||||
| import nc.jdbc.framework.processor.ColumnProcessor; | import nc.jdbc.framework.processor.ColumnProcessor; | ||||||
| import nc.jdbc.framework.processor.MapProcessor; | import nc.jdbc.framework.processor.MapProcessor; | ||||||
|  | @ -21,6 +22,8 @@ import nccloud.api.rest.utils.NCCRestUtils; | ||||||
| import nccloud.api.rest.utils.ResultMessageUtil; | import nccloud.api.rest.utils.ResultMessageUtil; | ||||||
| import nccloud.api.so.m30.IAPISaleOrderMaitain; | import nccloud.api.so.m30.IAPISaleOrderMaitain; | ||||||
| import nccloud.api.so.m30.IAPISaleOrderQuery; | import nccloud.api.so.m30.IAPISaleOrderQuery; | ||||||
|  | import nccloud.baseapp.core.log.NCCForUAPLogger; | ||||||
|  | import nccloud.commons.lang.StringUtils; | ||||||
| import nccloud.openapi.scmpub.pub.NCCPubRestResource; | import nccloud.openapi.scmpub.pub.NCCPubRestResource; | ||||||
| import nccloud.openapi.scmpub.pub.TransferCodeToPKTool; | import nccloud.openapi.scmpub.pub.TransferCodeToPKTool; | ||||||
| import nccloud.openapi.scmpub.pub.TransferMapToVOTool; | import nccloud.openapi.scmpub.pub.TransferMapToVOTool; | ||||||
|  | @ -483,4 +486,45 @@ public class SaleOrderResource extends NCCPubRestResource { | ||||||
|             return ResultMessageUtil.exceptionToJSON(e); |             return ResultMessageUtil.exceptionToJSON(e); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 金慧软件修改BIP销售订单明细 | ||||||
|  |      * | ||||||
|  |      * @author mzr | ||||||
|  |      * @date 2025/05/14 | ||||||
|  |      */ | ||||||
|  |     @POST | ||||||
|  |     @Path("updateDef") | ||||||
|  |     @Consumes({"application/json"}) | ||||||
|  |     @Produces({"application/json"}) | ||||||
|  |     public JSONString updateDef(Map<String, Object> paramMap) { | ||||||
|  |         String csaleorderbid = (String) paramMap.get("csaleorderbid"); | ||||||
|  |         if (StringUtils.isEmpty(csaleorderbid)) { | ||||||
|  |             return ResultMessageUtil.exceptionToJSON("传入参数为空,请检查", APIErrCodeEnum.BUSINESSEXCCODE.getCode()); | ||||||
|  |         } | ||||||
|  |         try { | ||||||
|  |             StringBuilder sql = new StringBuilder("update so_saleorder_b set "); | ||||||
|  |             SQLParameter parameter = new SQLParameter(); | ||||||
|  |             for (Map.Entry<String, Object> entry : paramMap.entrySet()) { | ||||||
|  |                 if (!"csaleorderbid".equals(entry.getKey())) { | ||||||
|  |                     sql.append(entry.getKey()).append(" = ?, "); | ||||||
|  |                     parameter.addParam(entry.getValue()); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             if (parameter.getCountParams() <= 0) { | ||||||
|  |                 return ResultMessageUtil.toJSON("传入参数为空,请检查", APIErrCodeEnum.BUSINESSEXCCODE.getCode()); | ||||||
|  |             } | ||||||
|  |             // 删除最后的", " | ||||||
|  |             sql.delete(sql.length() - 2, sql.length()); | ||||||
|  |             sql.append(" where csaleorderbid = ?"); | ||||||
|  |             NCCForUAPLogger.debug("updateDef-sql:" + sql); | ||||||
|  |             parameter.addParam(csaleorderbid); | ||||||
|  |             BaseDAO baseDAO = new BaseDAO(); | ||||||
|  |             int num = baseDAO.executeUpdate(sql.toString(), parameter); | ||||||
|  |             return ResultMessageUtil.toJSON(num, "销售订单修改成功"); | ||||||
|  |         } catch (BusinessException e) { | ||||||
|  |             return ResultMessageUtil.exceptionToJSON(e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue