From 197767b6e673ca1cad7bab8357e097e23d3f27ba Mon Sep 17 00:00:00 2001 From: mzr <1562242162@qq.com> Date: Tue, 25 Mar 2025 18:37:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E5=8D=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=BF=AE=E5=A4=8D=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=B7=B2=E8=A2=AB=E5=88=A0=E9=99=A4=E7=9A=84=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/GatheringbillRestResource.java | 2 +- .../nccloud/openapi/ArriveResourcesTest.java | 20 - .../nccloud/openapi/BaseOpenApiTest.java | 406 ------------------ 3 files changed, 1 insertion(+), 427 deletions(-) delete mode 100644 arap/src/public/nccloud/openapi/ArriveResourcesTest.java delete mode 100644 arap/src/public/nccloud/openapi/BaseOpenApiTest.java diff --git a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java index ae08f10..55ff250 100644 --- a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java +++ b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java @@ -343,7 +343,7 @@ import java.util.zip.GZIPInputStream; HYSuperDMO dmo = new HYSuperDMO(); - SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class, "vbillcode='" + def2 + "'"); + SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class, "csaleorderid='" + csaleorderid + "'"); SaleOrderBVO[] bvos = (SaleOrderBVO[]) dmo.queryByWhereClause(SaleOrderBVO.class, "csaleorderid='" + hvo[0].getPrimaryKey() + "'"); if (bvos != null) { itemvo.setSrc_billid(bvos[0].getCsaleorderid()); diff --git a/arap/src/public/nccloud/openapi/ArriveResourcesTest.java b/arap/src/public/nccloud/openapi/ArriveResourcesTest.java deleted file mode 100644 index ea131cf..0000000 --- a/arap/src/public/nccloud/openapi/ArriveResourcesTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package nccloud.openapi; - - -public class ArriveResourcesTest extends nccloud.openapi.BaseOpenApiTest { - public void save() { - String url = "/nccloud/api/pu/arrive/saveFromOrder"; - - try { - String result = requestOpenApiByJSON(url, "resources/Arrive.json"); - System.out.println(result); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void main(String[] args) { - ArriveResourcesTest test = new ArriveResourcesTest(); - test.save(); - } -} diff --git a/arap/src/public/nccloud/openapi/BaseOpenApiTest.java b/arap/src/public/nccloud/openapi/BaseOpenApiTest.java deleted file mode 100644 index 28cc9ce..0000000 --- a/arap/src/public/nccloud/openapi/BaseOpenApiTest.java +++ /dev/null @@ -1,406 +0,0 @@ -package nccloud.openapi; - - -import com.alibaba.fastjson.JSONObject; -import nc.ws.opm.pub.utils.security.SecurityUtil; -import nccloud.openapi.BaseOpenApiTest.HttpClientWapper.Response; -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.StringRequestEntity; -import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.lang3.StringUtils; -import org.springframework.core.io.ClassPathResource; -import sun.misc.BASE64Decoder; -import sun.misc.BASE64Encoder; - -import javax.crypto.Cipher; -import java.io.*; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.security.*; -import java.security.spec.X509EncodedKeySpec; -import java.util.*; -import java.util.Map.Entry; - -/** - * @description: 审批流程接口测试 - * @author:guoxqc@yonyou.com - * @date:2020年10月23日 - */ -public class BaseOpenApiTest { - // public static final String BASE_URL_DEV="http://192.168.82.5:9999"; - public static final String BASE_URL_DEV = "http://127.0.0.1:8088"; -// public static final String BASE_URL_DEV = "http://192.168.82.104:7788"; -// public static final String BASE_URL_DEV="http://192.168.82.1:9081"; -// public static final String BASE_URL_DEV="http://172.23.17.146:8001"; - /** - * APP ID - */ - public static final String CLIENT_ID; - /** - * APP Secret - */ - public static final String CLIENT_SECRET; - /** - * 公钥 - */ - public static final String PUBLIC_KEY; - /** - * 账套编码 - */ - public static final String BIZ_CENTER; - /** - * 用户编码 - */ - public static final String USER_CODE; - - static { - ResourceBundle config = ResourceBundle.getBundle("nccloud.openapi.config"); - CLIENT_ID = config.getString("client_id"); - CLIENT_SECRET = config.getString("client_secret"); - PUBLIC_KEY = config.getString("pub_key"); - BIZ_CENTER = config.getString("biz_center"); - USER_CODE = config.getString("user_code"); - } - - public HttpClientWapper client = new HttpClientWapper(); - - /** - * @param url - * @param param - * @return - * @throws Exception - */ - public String requestOpenApi(String url, Map param) throws Exception { - return requestOpenApi(url, new JSONObject(param)); - } - - /** - * @param url - * @param param - * @return - * @throws Exception - */ - public String requestOpenApi(String url, JSONObject param) throws Exception { - return requestOpenApi(url, param.toJSONString()); - } - - /** - * @param url - * @param fileName - * @return - * @throws Exception - */ - public String requestOpenApiByJSON(String url, String fileName) throws Exception { - ClassPathResource classPathResorce = new ClassPathResource(fileName, this.getClass()); - StringBuffer data = new StringBuffer(); - try { - InputStream in = classPathResorce.getInputStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8")); - String line = reader.readLine(); - while (StringUtils.isNotEmpty(line)) { - data.append(line); - line = reader.readLine(); - } - } catch (IOException e1) { - e1.printStackTrace(); - } - return requestOpenApi(url, data.toString()); - } - - public String requestOpenApi(String url, String param) throws Exception { - String accessToken = this.getAccessTokenByClient(); - System.out.println(param.replace(" ", "")); - String sign = digest(CLIENT_ID + PUBLIC_KEY); - List
headers = new ArrayList
(); - headers.add(new Header("Content-Type", "application/json;charset=UTF-8")); - headers.add(new Header("signature", sign)); - headers.add(new Header("ucg_flag", "y")); - headers.add(new Header("access_token", accessToken)); - headers.add(new Header("client_id", CLIENT_ID)); - Response response; - try { - response = client.post(BASE_URL_DEV + url, headers.toArray(new Header[headers.size()]), null, param); -// System.out.println(response.getData()); - return response.getData(); - } catch (Exception e) { - System.out.println(e.getMessage()); - e.printStackTrace(); - return e.getMessage(); - } - } - - /** - * @param seed 种子,用于生成公钥 - * @param src 明文 - * @return - * @throws Exception - * @description RSA加密 - */ - public String pubEncrypt(String seed, String src) throws Exception { - String target = null; - ByteArrayOutputStream out = null; - try { - Key key = genPublicKey(PUBLIC_KEY); - Cipher cipher = Cipher.getInstance("RSA"); - cipher.init(1, key); - byte[] data = src.getBytes(); - int inputLen = data.length; - out = new ByteArrayOutputStream(); - int offSet = 0; - int i = 0; - while (inputLen - offSet > 0) { - byte[] cache; - ; - if (inputLen - offSet > 117) { - cache = cipher.doFinal(data, offSet, 117); - } else { - cache = cipher.doFinal(data, offSet, inputLen - offSet); - } - out.write(cache, 0, cache.length); - i++; - offSet = i * 117; - } - target = new BASE64Encoder().encodeBuffer(out.toByteArray()); - } catch (Exception e) { - throw new Exception("加密失败" + e.getMessage()); - } finally { - if (out != null) { - out.close(); - } - } - return target; - } - - /** - * @param str - * @return - * @description 信息摘要 - */ - public static String digest(String str) { - String encodestr = ""; - try { - MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); - messageDigest.update(str.getBytes(StandardCharsets.UTF_8)); - encodestr = byte2Hex(messageDigest.digest()); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } - return encodestr; - } - - private static String byte2Hex(byte[] bytes) { - StringBuffer stringBuffer = new StringBuffer(); - String temp = null; - for (int i = 0; i < bytes.length; i++) { - temp = Integer.toHexString(bytes[i] & 0xFF); - if (temp.length() == 1) { - stringBuffer.append("0"); - } - stringBuffer.append(temp); - } - return stringBuffer.toString(); - } - - /** - * @param PUBLIC_KEY - * @return - * @throws Exception - * @description 根据种子生成密钥对 - */ - public static Key genPublicKey(String seed) throws Exception { - Key key = null; - try { - byte[] keyBytes = new BASE64Decoder().decodeBuffer(seed); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes); - key = keyFactory.generatePublic(x509KeySpec); - } catch (Exception e) { - throw new Exception("无效的密钥 " + e.getMessage()); - } - return key; - } - - /** - * Http请求包装类 - * - * @author guoxiangqiao - * @date 2019年12月11日 - */ - public class HttpClientWapper { - public static final int HTTP_STATUS_SUCCESS = 200; - - /** - * post请求 - * - * @param url - * @param headers - * @param requestBody - * @return - * @throws Exception - */ - public Response post(String url, Header[] headers, NameValuePair[] requestBody, String requestEntityStr) throws Exception { - HttpClient client = new HttpClient(); - PostMethod postMethod = new PostMethod(url); - if (headers != null) { - for (Header header : headers) { - postMethod.setRequestHeader(header); - } - } - if (requestBody != null) { - postMethod.setRequestBody(requestBody); - } - if (StringUtils.isNotEmpty(requestEntityStr)) { - StringRequestEntity requestEntity = new StringRequestEntity(requestEntityStr, null, "utf-8"); - postMethod.setRequestEntity(requestEntity); - } - int httpStatus = client.executeMethod(postMethod); - String result = this.getResponseBodyAsString(postMethod); - return new Response(httpStatus, result); - } - - public String getResponseBodyAsString(PostMethod postMethod) throws IOException { - byte[] rawdata = null; - rawdata = postMethod.getResponseBody(); - return rawdata != null ? EncodingUtil.getString(rawdata, "utf-8") : null; - } - - /** - * @param params - * @return - * @description Map转URL参数 - * @author guoxqc@yonyou.com - * @date 2020年10月22日 - */ - public String getURLParam(Map params) { - StringBuffer paramStr = new StringBuffer(); - if (!params.isEmpty()) { - for (Entry kv : params.entrySet()) { - paramStr.append(kv.getKey()); - paramStr.append("="); - paramStr.append(kv.getValue()); - paramStr.append("&"); - } - paramStr.deleteCharAt(paramStr.length() - 1); - } - return paramStr.toString(); - } - - /** - * get请求 - * - * @param url - * @param headers - * @param params - * @return - * @throws Exception - */ - public Response get(String url, Header[] headers, NameValuePair[] params) throws Exception { - HttpClient client = new HttpClient(); - GetMethod getMethod = new GetMethod(url); - if (params != null) { - getMethod.setQueryString(params); - } - if (headers != null) { - for (Header header : headers) { - getMethod.setRequestHeader(header); - } - } - int httpStatus = client.executeMethod(getMethod); - String result = getMethod.getResponseBodyAsString(); - return new Response(httpStatus, result); - } - - /** - * 获取url查询参数 - * - * @param params - * @return - */ - public String getQueryString(NameValuePair[] params) { - GetMethod getMethod = new GetMethod(); - getMethod.setQueryString(params); - return getMethod.getQueryString(); - } - - class Response { - private int httpStatus; - private String data; - - public int getHttpStatus() { - return httpStatus; - } - - public void setHttpStatus(int httpStatus) { - this.httpStatus = httpStatus; - } - - public String getData() { - return data; - } - - public void setData(String data) { - this.data = data; - } - - public Response(int httpStatus, String data) { - super(); - this.httpStatus = httpStatus; - this.data = data; - } - - public Response() { - super(); - } - } - } - - public static String getSHA256(String str, String key) throws Exception { - byte[] salt = new byte[16]; - SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); - random.setSeed(key.getBytes()); - random.nextBytes(salt); - String salt_value = new BASE64Encoder().encodeBuffer(salt); - return digest(str + salt_value.replaceAll("\r|\n", "")); - } - - /** - * @return - * @throws Exception - * @description 获取AccessToken - */ - @SuppressWarnings("static-access") - public String getAccessTokenByClient() throws Exception { - String url = BASE_URL_DEV + "/nccloud/opm/accesstoken"; - List
headers = new ArrayList
(); - headers.add(new Header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")); - // 获取信息摘要 - String signature = getSHA256(CLIENT_ID + CLIENT_SECRET + PUBLIC_KEY, PUBLIC_KEY); - // 使用PUBLIC_KEY生成公钥,对CLIENT_SECRET加密 - SecurityUtil securityUtil = new SecurityUtil(); - String CLIENT_SECRETEn = URLEncoder.encode(securityUtil.pubEncrypt(PUBLIC_KEY, CLIENT_SECRET), "utf-8"); - Map params = new HashMap(); - params.put("client_id", CLIENT_ID); - params.put("userCode", USER_CODE); - params.put("grant_type", "client_credentials"); - params.put("biz_center", BIZ_CENTER); - params.put("signature", signature); - params.put("client_secret", CLIENT_SECRETEn); - try { - Response response = client.post(url, headers.toArray(new Header[headers.size()]), null, client.getURLParam(params)); - System.out.println(response.getData()); - JSONObject result = JSONObject.parseObject(response.getData()); - boolean success = result.getBoolean("success"); - if (success) { - return result.getJSONObject("data").getString("access_token"); - } - } catch (Exception e) { - System.out.println(e.getMessage()); - e.printStackTrace(); - } - return null; - } -} \ No newline at end of file From 8722edd8b46b85733ea431292ff4889c81186c2e Mon Sep 17 00:00:00 2001 From: mzr <1562242162@qq.com> Date: Wed, 26 Mar 2025 11:18:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8D=95=E4=BB=B7=E6=9C=AA=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=81=94=E5=8A=A8=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java index 2235f6a..5048d4b 100644 --- a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java +++ b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java @@ -22,6 +22,7 @@ import nc.vo.pubapp.AppContext; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.pubapp.pflow.PfUserObject; import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule; +import nc.vo.scmpub.fill.pricemny.INumPriceMnyCalculator; import nc.vo.scmpub.res.billtype.SOBillType; import nc.vo.scmpub.util.StringUtil; import nc.vo.so.m30.entity.SaleOrderBVO; @@ -36,6 +37,7 @@ import nc.vo.so.pub.keyvalue.VOKeyValue; import nc.vo.so.pub.util.AggVOUtil; import nc.vo.so.pub.util.SOCurrencyUtil; import nccloud.api.impl.so.m30.check.SaleOrderValidator; +import nccloud.api.impl.so.m30.fill.SaleOrderNPriceMnyCal; import nccloud.api.impl.so.m30.fill.SaleOrderSaveFillValue; import nccloud.api.so.m30.IAPISaleOrderMaitain; import nccloud.baseapp.core.log.NCCForUAPLogger; @@ -296,6 +298,9 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { addBvo(combinBillVOs, paramList); } } + // 联动计算 + INumPriceMnyCalculator cal = new SaleOrderNPriceMnyCal(combinBillVOs); + cal.calculate(); for (SaleOrderVO vo : combinBillVOs) { SaleOrderHVO hvo = vo.getParentVO(); SaleOrderHVO originHvo = null; @@ -833,6 +838,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } SaleOrderBVO[] bvos = oldVO.getChildrenVO(); List bvoList = new ArrayList<>(Arrays.asList(bvos)); + // 添加新增行 bvoList.addAll(newBvoList); SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]); oldVO.setChildrenVO(array);