From ae51ee48cb4a422b5f91dd714a3ca29c8ce9e8b8 Mon Sep 17 00:00:00 2001 From: maolei Date: Fri, 16 May 2025 14:44:12 +0800 Subject: [PATCH 01/16] =?UTF-8?q?refactor(ic):=20=E9=87=8D=E6=9E=84=20Http?= =?UTF-8?q?PostOtherSysImpl=20=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 替换 HttpURLConnection 为 Apache HttpClient 实现 HTTP 请求 - 优化获取 token 和发送请求的逻辑 - 添加日志记录功能 - 异常处理机制 --- .../impl/utils/HttpPostOtherSysImpl.java | 226 +++++++++--------- .../commen/itf/utils/IHttpPostOtherSys.java | 36 +-- 2 files changed, 121 insertions(+), 141 deletions(-) diff --git a/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java b/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java index ec6f650..bfdc252 100644 --- a/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java +++ b/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java @@ -1,18 +1,24 @@ package nccloud.pubift.commen.impl.utils; -import com.alibaba.fastjson.JSONObject; -import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; -import java.io.BufferedReader; +import com.alibaba.fastjson.JSONObject; +import nc.bs.logging.Log; +import nc.vo.pub.BusinessException; +import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + 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"; @@ -21,137 +27,131 @@ public class HttpPostOtherSysImpl implements IHttpPostOtherSys { private static final String EP_ID = ""; private static final String LOGIN_URL = "/GTHINKING/AjaxService/N_MISPRO/100208057.ashx/Login"; + private static final String LOG_INFO_NAME = "OALOG"; + + private static final Log obmlog = Log.getInstance(LOG_INFO_NAME); @Override public String callMes(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); + String tokenValue = this.getMESToken(mesip); Map headers = new HashMap<>(); - headers.put("Set-Cookie", cookie); + if (tokenValue != null) { + headers.put("Cookie", ".ASPXAUTH=" + tokenValue); + } 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); + /** + * ݵⲿϵͳ + */ + public void sendToExternalSystem(String apiPath, Map requestData) throws BusinessException { + try { + obmlog.debug("HttpPostOtherSys request :" + JSONObject.toJSONString(requestData)); + JSONObject jsonRequest = new JSONObject(requestData); + String response = callMes(apiPath, jsonRequest); + JSONObject jsonResponse = JSONObject.parseObject(response); + + obmlog.debug("ӿڷ:" + jsonResponse.toJSONString()); + + String success = jsonResponse.getString("Success"); + if ("false".equals(success)) { + String errorMessage = jsonResponse.getString("ErrorMessage"); + if (errorMessage == null) { + errorMessage = "No error message provided by the external system."; + } + throw new BusinessException("ͬmesϵͳʧ,Ϣ" + errorMessage); + } + + } catch (BusinessException e) { + throw e; + } catch (Exception e) { + throw new BusinessException("ⲿӿʧܣ" + e.getMessage(), e); + } } /** * ҵpost */ - private String doPost(String baseurl, Map 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)); + private String doPost(String baseurl, Map headers, JSONObject jsonPayload) { + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpPost httpPost = new HttpPost(baseurl); + + // Set standard headers + httpPost.setHeader("Content-Type", "application/json;charset=UTF-8"); + + // Set custom headers from the map + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + httpPost.setHeader(entry.getKey(), entry.getValue()); } } - connection.connect(); - // һҪBufferedReader Ӧ ʹֽӦķǽղݵ - OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); // UTF-8 - if (json != null) { - out.append(json.toString()); + + if (jsonPayload != null) { + StringEntity stringEntity = new StringEntity(jsonPayload.toJSONString(), "UTF-8"); + httpPost.setEntity(stringEntity); } - out.flush(); - out.close(); - // ȡӦ - reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); - String line; - String res = ""; - while ((line = reader.readLine()) != null) { - res += line; + + try (CloseableHttpResponse response = httpClient.execute(httpPost)) { + HttpEntity entity = response.getEntity(); + String responseString = EntityUtils.toString(entity, "UTF-8"); + return responseString; } - reader.close(); - return res; - } catch (Exception e) { -// e.printStackTrace(); - throw new RuntimeException(e); + } catch (IOException e) { + // In a real application, use a proper logging framework + // e.printStackTrace(); + throw new RuntimeException("HTTP POST request to " + baseurl + " failed: " + e.getMessage(), e); } } - /** - * ȡcookiepost - */ - private String postCookie(String baseurl, Map 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"); + // ȡ .ASPXAUTH ֵ - This method remains unchanged + private String extractAspxAuth(String setCookieHeaderLine) { + // setCookieHeaderLine һ Set-Cookie Ӧͷ: + // ".ASPXAUTH=TOKEN_VALUE; path=/; HttpOnly" + // ".ASPXAUTH=TOKEN_VALUE;" + String[] cookieAttributes = setCookieHeaderLine.split(";"); // ֺŷָ + for (String attribute : cookieAttributes) { + String trimmedAttribute = attribute.trim(); // ȥǰո + if (trimmedAttribute.startsWith(".ASPXAUTH=")) { + return trimmedAttribute.substring(".ASPXAUTH=".length()); // ȡȺźֵ + } + } + return null; // ûҵ .ASPXAUTH + } - if (map != null) { - for (String key : map.keySet()) { - connection.setRequestProperty(key, map.get(key)); + private String getMESToken(String mesIpBase) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("userId", USER_ID); + jsonObject.put("password", PASSWORD); + jsonObject.put("clientType", CLIENT_TYPE); + jsonObject.put("epId", EP_ID); + + String loginUrl = mesIpBase + LOGIN_URL; + + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpPost httpPost = new HttpPost(loginUrl); + httpPost.setHeader("Content-Type", "application/json;charset=UTF-8"); + + StringEntity stringEntity = new StringEntity(jsonObject.toJSONString(), "UTF-8"); + httpPost.setEntity(stringEntity); + + try (CloseableHttpResponse response = httpClient.execute(httpPost)) { + Header[] setCookieHeaders = response.getHeaders("Set-Cookie"); + if (setCookieHeaders != null) { + for (Header header : setCookieHeaders) { + String aspxAuthValue = extractAspxAuth(header.getValue()); + if (aspxAuthValue != null) { + return aspxAuthValue; // Found and return .ASPXAUTH token value + } + } } - } - connection.connect(); - - // д - OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); - if (json != null) { - out.append(json.toString()); + return null; // Return null if .ASPXAUTH cookie is not found, as per } - out.flush(); - out.close(); + } catch (IOException e) { - // ȡӦͷе Set-Cookie - Map> headers = connection.getHeaderFields(); - String setCookieHeader = null; - - for (Map.Entry> 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(); - } - } + throw new RuntimeException("Failed to get MESToken (cookie) from " + loginUrl + " due to IO issue: " + e.getMessage(), e); } } - // ȡ .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; - } } diff --git a/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java b/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java index 2b4ba2e..0dfa373 100644 --- a/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java +++ b/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java @@ -1,48 +1,28 @@ package nccloud.pubift.commen.itf.utils; + import com.alibaba.fastjson.JSONObject; -import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Log; import nc.vo.pub.BusinessException; -import java.util.Iterator; import java.util.Map; public interface IHttpPostOtherSys { + String logginfo = "OALOG"; + + Log obmlog = Log.getInstance(logginfo); + /** * @param apiPath MESĽӿڵַip - * @param json + * @param json */ public String callMes(String apiPath, JSONObject json); /** * ݵⲿϵͳ */ - default void sendToExternalSystem(String apiPaht, Map requestData) throws BusinessException { - try { - IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); - JSONObject jsonRequest = new JSONObject(requestData); - String response = httpService.callMes(apiPaht, jsonRequest); - JSONObject jsonResponse = JSONObject.parseObject(response); + public void sendToExternalSystem(String apiPaht, Map requestData) throws BusinessException; - int code = jsonResponse.getIntValue("code"); - if (code != 0) { - throw new Exception("Զ嵵ͬʧܣ룺" + code + "Ϣ" + jsonResponse.getString("message")); - } - - if (jsonResponse.containsKey("data") && !jsonResponse.getJSONObject("data").isEmpty()) { - JSONObject data = jsonResponse.getJSONObject("data"); - StringBuilder errorMsg = new StringBuilder("Զ嵵ִͬ"); - Iterator keys = data.keySet().iterator(); - while (keys.hasNext()) { - String key = keys.next(); - errorMsg.append("\n ").append(key).append(": ").append(data.get(key)); - } - throw new Exception(errorMsg.toString()); - } - } catch (Exception e) { - throw new BusinessException("ⲿӿʧܣ" + e.getMessage(), e); - } - } } From 3ed9c679f6dd494d80ed17aa8c528dfc573989d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Fri, 16 May 2025 16:51:22 +0800 Subject: [PATCH 02/16] =?UTF-8?q?2312=E6=95=B0=E7=94=B5=E7=BA=B8=E8=B4=A8?= =?UTF-8?q?=E5=8F=91=E7=A5=A8=E4=B8=8D=E6=A0=A1=E9=AA=8C=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E6=96=B9=E5=9C=B0=E5=9D=80=E7=94=B5=E8=AF=9D=E9=93=B6=E8=A1=8C?= =?UTF-8?q?=E8=B4=A6=E6=88=B7=5F=E9=80=82=E9=85=8D=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ivsale/rule/IVApplicationCheckRule.java | 454 ++++++++++++++++++ 1 file changed, 454 insertions(+) create mode 100644 sscivm/src/public/nc/bs/sscivm/ivsale/rule/IVApplicationCheckRule.java diff --git a/sscivm/src/public/nc/bs/sscivm/ivsale/rule/IVApplicationCheckRule.java b/sscivm/src/public/nc/bs/sscivm/ivsale/rule/IVApplicationCheckRule.java new file mode 100644 index 0000000..6ed15e2 --- /dev/null +++ b/sscivm/src/public/nc/bs/sscivm/ivsale/rule/IVApplicationCheckRule.java @@ -0,0 +1,454 @@ +package nc.bs.sscivm.ivsale.rule; + +import nc.bs.framework.common.NCLocator; +import nc.bs.sscivm.ivsale.ivaconst.IVAWebConst; +import nc.bs.sscivm.ivsale.util.IVApplicationTspzUtil; +import nc.bs.sscivm.logger.SSCIVMLogger; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.itf.sscivm.service.IVMInvoiceQueryService; +import nc.vo.pub.BusinessException; +import nc.vo.pub.VOStatus; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDouble; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.sscivm.invoice.IVMInvoiceAggVO; +import nc.vo.sscivm.ivmpub.IVAplocationFPXZ; +import nc.vo.sscivm.ivmpub.IVAplocationZSFS; +import nc.vo.sscivm.ivmpub.InvoiceTypeEnum; +import nc.vo.sscivm.ivsale.IVApplicationAggVO; +import nc.vo.sscivm.ivsale.IVApplicationBodyVO; +import nc.vo.sscivm.ivsale.IVApplicationHeadVO; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class IVApplicationCheckRule implements IRule{ + @Override + public void process(IVApplicationAggVO[] vos) { + // У鵥ݵĹϢ + if(vos != null && vos.length > 0){ + for (IVApplicationAggVO aggVO : vos) { + // ֵ˰ר÷ƱУͻơͻ˰ʶšַ绰м˺ + Integer fplx = aggVO.getParentVO().getFplx(); + UFBoolean sgbz = aggVO.getParentVO().getSgbz(); + if (InvoiceTypeEnum.getSpecialInvoice().contains(fplx) && (sgbz == null || !sgbz.booleanValue())) { + checkHeadNull(aggVO); + } else if (sgbz != null && sgbz.booleanValue()){//չͷп + checkSGHeadNull(aggVO); + } else { + // ͷƱͻƲΪ + if (isEmpty(aggVO.getParentVO().getGmf_mc())) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0044")/*@res "͵ķƱƲΪ"*/); + } + } + + //ԭУ + checkCommonInvoice(aggVO); + + // УıĿơ + checkBodyNull(aggVO); + // УۿкźͱۿкźϷ + checkBodyValid(aggVO); + //УͷǷһ + checkAmount(aggVO); + + if (fplx == InvoiceTypeEnum.INVOICETYPE_ZYFP_JDC.toIntValue()){ + //ר÷ƱλУ + checkDw(aggVO); + } + + //෢ƱУ + if (InvoiceTypeEnum.getKCLInvoice().contains(fplx)){ + checkKCL(aggVO); + } + + //ƱУ + checkTspz(aggVO); + + } + } + } + + private void checkBodyNull(IVApplicationAggVO aggVO) throws RuntimeException { + IVApplicationBodyVO[] applicationBodyVOs = (IVApplicationBodyVO[])aggVO.getChildrenVO(); + List applicationBodyVOList = new ArrayList<>(); + + if(applicationBodyVOs != null && applicationBodyVOs.length > 0){ + for(IVApplicationBodyVO bodyvo : applicationBodyVOs){ + if(bodyvo.getStatus() != VOStatus.DELETED){ + applicationBodyVOList.add(bodyvo); + } + } + } + applicationBodyVOs = applicationBodyVOList.toArray(new IVApplicationBodyVO[0]); + IVApplicationHeadVO hvo = aggVO.getParentVO(); + Integer fplx = hvo.getFplx(); + + if (applicationBodyVOs != null && applicationBodyVOs.length > 0) { + for (IVApplicationBodyVO applicationBodyVO : applicationBodyVOs) { + if (applicationBodyVO.getXmmc() == null) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0047")/*@res "Ʊ뵥еƲΪգ"*/); + } + + if (hvo.getSgbz() == null || !hvo.getSgbz().booleanValue() && (hvo.getHzfp() == null || !hvo.getHzfp().booleanValue()) && (hvo.getZffp() == null || !hvo.getZffp().booleanValue()) && (hvo.getCkfp() == null || !hvo.getCkfp().booleanValue())){ + if (applicationBodyVO.getPk_materiel() != null && applicationBodyVO.getTaxcode() == null) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0159")/*@res "Ʊ뵥е˰벻Ϊգ"*/); + } + } + // ƷͨƱƷר÷ƱƷͨƱ(ʽ)ֵ˰ͨƱƷͣDZ + if (fplx == InvoiceTypeEnum.INVOICETYPE_CPYPTFP.toIntValue() + || fplx == InvoiceTypeEnum.INVOICETYPE_CPYZXFP.toIntValue() + || fplx == InvoiceTypeEnum.INVOICETYPE_CPYPTFP_JS.toIntValue() + || fplx == InvoiceTypeEnum.INVOICETYPE_DZPTFP_CPY.toIntValue()) { + if (applicationBodyVO.getXmsl() == null || applicationBodyVO.getXmsl().doubleValue() == 0.0) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0059")/*@res "͵ķƱеΪգ"*/); + } + } + } + } else { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0099")/*@res "ݲΪ"*/); + } + } + + private void checkBodyValid(IVApplicationAggVO aggVO) { + IVApplicationBodyVO[] applicationBodyVOs = (IVApplicationBodyVO[])aggVO.getChildrenVO(); + List applicationBodyVOList = new ArrayList<>(); + + if(applicationBodyVOs != null && applicationBodyVOs.length > 0){ + for(IVApplicationBodyVO bodyvo : applicationBodyVOs){ + if(bodyvo.getStatus() != VOStatus.DELETED){ + applicationBodyVOList.add(bodyvo); + } + } + } + applicationBodyVOs = applicationBodyVOList.toArray(new IVApplicationBodyVO[0]); + if((null == aggVO.getParentVO().getHzfp() || UFBoolean.FALSE.equals(aggVO.getParentVO().getHzfp())) + && (null == aggVO.getParentVO().getZffp() || UFBoolean.FALSE.equals(aggVO.getParentVO().getZffp()))){ + Map rowNumAndBodyMap = new HashMap<>(); + Map rowNumAndXmmc = new HashMap<>(); + Map hhMap = new HashMap(); + for (IVApplicationBodyVO applicationBodyVO : applicationBodyVOs) { + if (applicationBodyVO.getHh() != null){ + if (hhMap.get("hh"+applicationBodyVO.getHh()) != null){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0109")/*"кŲظ"*/); + } else { + hhMap.put("hh"+applicationBodyVO.getHh(), "hh"+applicationBodyVO.getHh()); + } + } + if(!StringUtils.isEmpty(applicationBodyVO.getZkhhh())){ + if (applicationBodyVO.getFphxz() == null || IVAplocationFPXZ.PFPXZ_BZKH.toIntValue() != applicationBodyVO.getFphxz()){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0156")/*"ǰвDZۿУۿкŲֵ"*/); + } + if (hhMap.get("zkhhh"+applicationBodyVO.getZkhhh()) != null){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0110")/*"ۿкŲظ"*/); + } else { + hhMap.put("zkhhh"+applicationBodyVO.getZkhhh(), "zkhhh"+applicationBodyVO.getZkhhh()); + } + } + // Уۿкͱۿϵкű + if (applicationBodyVO.getFphxz() !=null && IVAplocationFPXZ.PFPXZ_BZKH.toIntValue() == applicationBodyVO.getFphxz() && StringUtils.isEmpty(applicationBodyVO.getZkhhh())) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0097")/*@res "ۿеۿкŲΪ"*/); + } else if (applicationBodyVO.getFphxz() !=null && IVAplocationFPXZ.FPXZ_ZKH.toIntValue() == applicationBodyVO.getFphxz() && StringUtils.isEmpty(applicationBodyVO.getHh())) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0098")/*@res "ۿекŲΪ"*/); + } + // ۿ뱻ۿнУ + if ( (applicationBodyVO.getFphxz() != null && IVAplocationFPXZ.PFPXZ_BZKH.toIntValue() == applicationBodyVO.getFphxz()) + && applicationBodyVO.getXmjshj().compareTo(UFDouble.ZERO_DBL) < 0){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0108")/*@res "ֿƱ뱻ۿнΪ"*/); + } + if ( (applicationBodyVO.getFphxz() == null || IVAplocationFPXZ.FPXZ_ZKH.toIntValue() == applicationBodyVO.getFphxz()) + && applicationBodyVO.getXmjshj().compareTo(UFDouble.ZERO_DBL) > 0){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0137")/*@res "ֿƱ뵥ۿнܴ㣬޸Ϊ"*/); + } + if (applicationBodyVO.getFphxz() !=null && IVAplocationFPXZ.FPXZ_ZKH.toIntValue() == applicationBodyVO.getFphxz()){ + rowNumAndBodyMap.put(applicationBodyVO.getHh(), applicationBodyVO); + rowNumAndXmmc.put(applicationBodyVO.getHh(), applicationBodyVO.getXmmc()); + } + } + for (IVApplicationBodyVO applicationBodyVO : applicationBodyVOs) { + if (applicationBodyVO.getFphxz() !=null && IVAplocationFPXZ.PFPXZ_BZKH.toIntValue() == applicationBodyVO.getFphxz() && !rowNumAndBodyMap.containsKey(applicationBodyVO.getZkhhh())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0099")/*@res "ۿ뱻ۿУ鲻ͨ"*/); + } + } + // Уۿ뱻ۿǷһ add by ligru 20201203 + int zkhNum = 0, bzkhNum = 0; + Map zkhMap = new HashMap(); + for (IVApplicationBodyVO applicationBodyVO : applicationBodyVOs) { + if (applicationBodyVO.getFphxz() !=null && IVAplocationFPXZ.PFPXZ_BZKH.toIntValue() == applicationBodyVO.getFphxz()){ + bzkhNum++; + } else if(applicationBodyVO.getFphxz() !=null && IVAplocationFPXZ.FPXZ_ZKH.toIntValue() == applicationBodyVO.getFphxz()){ + zkhMap.put(applicationBodyVO.getHh(), applicationBodyVO); + zkhNum++; + } + } + if(zkhNum != bzkhNum){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0099")/*@res "ۿ뱻ۿУ鲻ͨ"*/); + } + // Уۿ뱻ۿĿǷͬ + for (IVApplicationBodyVO applicationBodyVO : applicationBodyVOs) { + if (applicationBodyVO.getFphxz() != null + && IVAplocationFPXZ.PFPXZ_BZKH.toIntValue() == applicationBodyVO.getFphxz() + && !java.util.Objects.equals(rowNumAndXmmc.get(applicationBodyVO.getZkhhh()), applicationBodyVO.getXmmc())) + { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( + "1058sal_0", + "01058sal-0116", + null, + new String[] { rowNumAndXmmc.get(applicationBodyVO.getZkhhh()), applicationBodyVO.getXmmc() }/*@res ۿĿ[{0}]뱻ۿĿ[{1}]һ*/)); + } + + if(applicationBodyVO.getFphxz() != null + && IVAplocationFPXZ.PFPXZ_BZKH.toIntValue() == applicationBodyVO.getFphxz() + && applicationBodyVO.getXmjshj().add(zkhMap.get(applicationBodyVO.getZkhhh()).getXmjshj()).doubleValue() <0){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0120")/*"ۿеĽӦۿн"*/); + } + } + } + } + + private void checkSGHeadNull(IVApplicationAggVO aggVO) throws RuntimeException{ + if(isEmpty(aggVO.getParentVO().getXsf_mc())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0193")/*@res "չƱ۷ƲΪ"*/); + } + if(isEmpty(aggVO.getParentVO().getXsf_nsrsbh())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0194")/*@res "չƱ۷˰ʶŲΪ"*/); + } + } + + private void checkHeadNull(IVApplicationAggVO aggVO) throws RuntimeException { + if(isEmpty(aggVO.getParentVO().getGmf_mc())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0040")/*@res "ֵ˰ר÷ƱƲΪ"*/); + } + + if(isEmpty(aggVO.getParentVO().getGmf_nsrsbh())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0041")/*@res "ֵ˰ר÷Ʊ˰ʶŲΪ"*/); + } + //ȫרƱУַ绰˺ + if(aggVO.getHeadVO().getFplx() == InvoiceTypeEnum.DZFP_ZZSZYFP.toIntValue() || aggVO.getHeadVO().getFplx() == InvoiceTypeEnum.ZZFP_ZZSZYFP.toIntValue() + || aggVO.getHeadVO().getFplx() == InvoiceTypeEnum.ZZFP_SDFP.toIntValue()){ + return; + } + if(isEmpty(aggVO.getParentVO().getGmf_dzdh())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0042")/*@res "ֵ˰ר÷Ʊ򷽵ַ绰Ϊ"*/); + } + + if(isEmpty(aggVO.getParentVO().getGmf_yhzh())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0043")/*@res "ֵ˰ר÷Ʊ˺ŲΪ"*/); + } + + } + + private void checkCommonInvoice(IVApplicationAggVO aggVO) throws RuntimeException { + + //ƱԭΪ,רƱϢΪ@˰˵ԭ@ + if (aggVO.getHeadVO().getHzfp() != null && aggVO.getHeadVO().getHzfp().booleanValue()){ + if ((InvoiceTypeEnum.getCommonInvoice().contains(aggVO.getHeadVO().getFplx()) || InvoiceTypeEnum.DZFP_ZZSZYFP.toIntValue()==aggVO.getHeadVO().getFplx())){ + if (isEmpty(aggVO.getParentVO().getHcyy())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0185")/*"ԭΪ"*/); + } + + IVApplicationBodyVO[] applicationBodyVOs = (IVApplicationBodyVO[])aggVO.getChildrenVO(); + for (IVApplicationBodyVO applicationBodyVO : applicationBodyVOs){ + //Уɾ + if (applicationBodyVO.getStatus() == VOStatus.DELETED){ + continue; + } + if (applicationBodyVO.getSpbm() != null){ + //˰ձΪ12ͷijԭѡ񡰷ֹ + if ((applicationBodyVO.getSpbm().startsWith("1") ||applicationBodyVO.getSpbm().startsWith("2")) && aggVO.getParentVO().getHcyy().equals("3")){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0186")/*"ǰ˰ձĺԭѡ:ֹ"*/); + } + //˰ձΪ3ͷijԭѡ˻ء + if (applicationBodyVO.getSpbm().startsWith("3") && aggVO.getParentVO().getHcyy().equals("1")){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0187")/*"ǰ˰ձĺԭѡ:˻"*/); + } + } + } + + //ַƱһʱԭѡá + String condition = "fpdm='"+aggVO.getHeadVO().getFpdm()+"' and fphm='"+aggVO.getHeadVO().getFphm()+"' and dr = 0 and (billtypecode = 'SSIV-Cxx-sale' or (billtypecode = 'SSIV-Cxx-rec' and invoice_type in (109,309) )) "; + if (aggVO.getHeadVO().getFpdm() == null){ + condition = " fphm='"+aggVO.getHeadVO().getFphm()+"' and dr = 0 and (billtypecode = 'SSIV-Cxx-sale' or (billtypecode = 'SSIV-Cxx-rec' and invoice_type in (109,309) )) "; + } + try { + IVMInvoiceAggVO[] vos = NCLocator.getInstance().lookup(IVMInvoiceQueryService.class).queryAggVOsByCondition(condition); + if (vos != null){ + if ((vos[0].getHeadVO().getJshj().add(aggVO.getHeadVO().getJshj())).compareTo(UFDouble.ZERO_DBL) == 0 && aggVO.getParentVO().getHcyy().equals("4")){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0188")/*"ȫԭѡ:"*/); + } + } + } catch (BusinessException e) { + SSCIVMLogger.error(e.getMessage(), e); + throw new RuntimeException(e); + } + + } + + if (InvoiceTypeEnum.getSpecialInvoice().contains(aggVO.getHeadVO().getFplx()) && aggVO.getHeadVO().getFplx() != InvoiceTypeEnum.DZFP_ZZSZYFP.toIntValue() && isEmpty(aggVO.getParentVO().getHzxxsqb())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0189")/*"ϢΪ"*/); + } + } + } + + /** + * УͷǷһ + * @param aggVO + */ + private void checkAmount(IVApplicationAggVO aggVO) { + UFDouble jshj = UFDouble.ZERO_DBL; + UFDouble hjje = UFDouble.ZERO_DBL; + UFDouble hjse = UFDouble.ZERO_DBL; + + //ϼ + for (IVApplicationBodyVO bodyvo : aggVO.getBodyVOs()){ + if (bodyvo.getStatus() == VOStatus.DELETED){ + continue; + } + jshj = jshj.add(bodyvo.getXmjshj() == null ? UFDouble.ZERO_DBL : bodyvo.getXmjshj()); + hjje = hjje.add(bodyvo.getXmje() == null ? UFDouble.ZERO_DBL : bodyvo.getXmje()); + hjse = hjse.add(bodyvo.getSe() == null ? UFDouble.ZERO_DBL : bodyvo.getSe()); + } + + IVApplicationHeadVO headvo = aggVO.getHeadVO(); + //˰ϼж + if (headvo.getJshj().compareTo(jshj) != 0){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0160")/*"ͷ˰ϼƲһ!"*/); + } + //˰ж + if (headvo.getHjje().compareTo(hjje) != 0){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0161")/*"ͷ˰һ!"*/); + } + //˰ж + if (headvo.getHjse().compareTo(hjse) != 0){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0162")/*"ͷ˰һ!"*/); + } + } + + /** + * Уר÷Ʊλ + * @param aggVO + */ + private void checkDw(IVApplicationAggVO aggVO){ + for (IVApplicationBodyVO body : aggVO.getBodyVOs()){ + if (body == null || !nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0225")/*@res ""*/.equals(body.getDw())){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0155", null, new String[] {nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0225")/*@res ""*/})/*"ֵ˰ר÷Ʊ()λΪ޸ģ"*/); + } + } + } + + /** + * ෢ƱУ + * @param aggVO ƱVO + */ + private void checkKCL(IVApplicationAggVO aggVO){ + for (IVApplicationBodyVO body : aggVO.getBodyVOs()){ + //Уɾ + if (body.getStatus() == VOStatus.DELETED){ + continue; + } + //λУ + if(body.getDw() == null || (!nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0226")/*@res ""*/.equals(body.getDw()) && !nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0227")/*@res ""*/.equals(body.getDw()) && !nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0228")/*@res "ǧ"*/.equals(body.getDw()) && !nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0229")/*@res ""*/.equals(body.getDw())&& !nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0230")/*@res ""*/.equals(body.getDw()))){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0190", null, new String[]{nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0","01058sal-0231")/*@res "ס֡ǧˡˡ"*/})/*"෢ƱλΪ:ס֡ǧˡˡ!"*/); + } + //У + if (body.getXmsl() == null || body.getXmsl().compareTo(UFDouble.ZERO_DBL) == 0 || body.getXmdj() == null || body.getXmdj().compareTo(UFDouble.ZERO_DBL) == 0){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0191")/*"෢ƱΪ!"*/); + } + //˰շ벻ΪʱУ飺˰Ϊ102Ʒͷҷ102040303ϡƷͷƷ + //˰շΪΪգƷ롱ֶκΪ˰շ룬ʱУ飺˰Ϊ102Ʒͷҷ102040303ϡƷͷƷ + if ((!StringUtils.isEmpty(body.getSsflbm()) && (!body.getSsflbm().startsWith("102") || body.getSsflbm().startsWith("102040303"))) + ||(StringUtils.isEmpty(body.getSsflbm()) && StringUtils.isEmpty(body.getPk_materiel()) &&(StringUtils.isEmpty(body.getSpbm()) || !body.getSpbm().startsWith("102") || body.getSpbm().startsWith("102040303")))){ + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0192", null, new String[]{"102", "102040303"})/*"෢Ʊ˰շΪ102Ʒͷҷ102040303ϡƷͷƷ!"*/); + } + } + } + + + public void checkTspz(IVApplicationAggVO aggVO) { + + String tspz = aggVO.getParentVO().getTspz() == null ? null : IVApplicationTspzUtil.getTspzCode( aggVO.getParentVO().getTspz()); + //ƱΪE06ޡE05ۡE03ʱΪƱʱƱϸֻһϸУһۿ뱻ۿ + String zsfs = aggVO.getParentVO().getZsfs(); + if(IVAWebConst.TSPZ_JZFW.equals(tspz)|| + IVAWebConst.TSPZ_BDCXS.equals(tspz) || + IVAWebConst.TSPZ_BDCZN.equals(tspz) || + String.valueOf(IVAplocationZSFS.HCYY_CEZS.toIntValue()).equals(zsfs) + ) { + //жϱǷ + boolean bodyflag = false; + IVApplicationBodyVO[] bodys = aggVO.getBodyVOs(); + //ɾı + List unDelBodys = new ArrayList<>(); + for (IVApplicationBodyVO body : bodys){ + if (body.getStatus() != VOStatus.DELETED){ + unDelBodys.add(body); + } + } + bodys = unDelBodys.toArray(new IVApplicationBodyVO[0]); + if(bodys!=null && bodys.length>2) { + bodyflag =true; + }else if(bodys!=null && bodys.length==2){ + for(IVApplicationBodyVO body:bodys) { + int fphxz = body.getFphxz(); + //жǷۿۼۿ + if(IVAplocationFPXZ.FPXZ_ZKH.toIntValue()!= fphxz && IVAplocationFPXZ.PFPXZ_BZKH.toIntValue()!=fphxz) { + bodyflag = true; + } + } + } + if(bodyflag) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0263")/*@res "ƱضҵƱʱɶп!"*/); + } + } + + if( IVAWebConst.TSPZ_BDCXS.equals(tspz) || IVAWebConst.TSPZ_BDCZN.equals(tspz)) { + String bdcdz = aggVO.getParentVO().getBdcdz(); + if (bdcdz == null ||(!bdcdz.contains("") && !bdcdz.contains("·") && !bdcdz.contains("") && !bdcdz.contains("") && !bdcdz.contains("")&& !bdcdz.contains("") && !bdcdz.contains("") && !bdcdz.contains(""))) { + ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", + "01058sal-0265")/*@res "ַ֡·塢硢 򡢵ŵһؼ"*/); + } + } + + } + public boolean isEmpty(String str) { + return StringUtils.isBlank(str) || "null".equals(str); + } + +} From df12cbce7c4a20f5dbed957b0a3e6cbd0b7a4222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Fri, 16 May 2025 18:07:20 +0800 Subject: [PATCH 03/16] =?UTF-8?q?arap=5F=E8=AE=A2=E5=8D=95=E6=94=B6?= =?UTF-8?q?=E6=AC=BE=E8=BF=87=E6=BB=A4=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/nc/api/arap/resource/GatheringbillRestResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java index 28fd1ff..ffbb5bd 100644 --- a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java +++ b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java @@ -270,7 +270,7 @@ public class GatheringbillRestResource extends ArapBaseRestResource { HYSuperDMO dmo = new HYSuperDMO(); SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class, - "vbillcode='" + def2 + "'"); + "vbillcode='" + def2 + "' and dr=0"); SaleOrderBVO[] bvos = (SaleOrderBVO[]) dmo.queryByWhereClause(SaleOrderBVO.class, "csaleorderid='" + hvo[0].getPrimaryKey() + "'"); if (bvos != null) { From f237cd1f40847de3909671e9998f823b2883ea92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Sat, 17 May 2025 15:55:17 +0800 Subject: [PATCH 04/16] =?UTF-8?q?ic=5Fuapbd=5F=E9=94=80=E5=94=AE=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E7=AD=BE=E5=AD=97=E6=8E=A8=E9=80=81=E9=94=90=E5=88=B6?= =?UTF-8?q?MOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ic/src/private/nc/bs/ic/m4c/sign/SignBP.java | 3 + .../rule/AfterSigningSynchronizeRuleRZ.java | 161 ++++++++++++++++++ .../uapbd/util/ThirdPartyPostRequestUtil.java | 68 ++++++++ 3 files changed, 232 insertions(+) create mode 100644 ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java create mode 100644 uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java diff --git a/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java b/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java index 96970de..1d916a1 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java @@ -53,6 +53,9 @@ public class SignBP implements ISignBP, ISignRuleProvider // ۳ ǩֺ ͬMES˼άϵͳ processor.addAfterRule(new AfterSigningSynchronizeRule()); // ̵㣨MES + + // ۳ ǩֺ ͬ + processor.addAfterRule(new AfterSigningSynchronizeRuleRZ()); } public void addBeforeRule(SaleOutVO[] vos, AroundProcesser processor) { diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java new file mode 100644 index 0000000..01ce6b2 --- /dev/null +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java @@ -0,0 +1,161 @@ +package nc.bs.ic.m4c.sign.rule; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.dao.BaseDAO; +import nc.bs.logging.Log; +import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.pubitf.para.SysInitQuery; +import nc.vo.bd.cust.CustomerVO; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.stordoc.StordocVO; +import nc.vo.cmp.util.StringUtils; +import nc.vo.ic.m4c.entity.SaleOutBodyVO; +import nc.vo.ic.m4c.entity.SaleOutHeadVO; +import nc.vo.ic.m4c.entity.SaleOutVO; +import nc.vo.org.DeptVO; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFDate; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.scmpub.util.ArrayUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Classname AfterSigningSynchronizeRuleRZ + * @Description TODO + * @Version 1.0.0 + * @Date 2025/5/16 9:01 + * @Created by ame + */ +public class AfterSigningSynchronizeRuleRZ implements IRule { + private static Log log=Log.getInstance("rzmomlog"); + + private static BaseDAO dao = new BaseDAO(); + @Override + public void process(SaleOutVO[] saleOutVOS) { + if(ArrayUtil.isEmpty(saleOutVOS)){ + return; + } + try{ + //鲢ɸѡ۳ⵥΪ˾ + List newSaleOutVOS= checkAndFilterBillSrcOrg(saleOutVOS); + if(newSaleOutVOS==null||newSaleOutVOS.size()<1){ + return; + } + pushToRZMOM(newSaleOutVOS.toArray(new SaleOutVO[0])); + }catch (Exception e){ + ExceptionUtils.wrappException(e); + } + } + + private List checkAndFilterBillSrcOrg(SaleOutVO[] saleOutVOS) throws BusinessException { + List aggvoList=new ArrayList<>(); + for(SaleOutVO aggvo:saleOutVOS){ + String pkOrg = aggvo.getHead().getPk_org(); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if("30401".equals(orgCode)){ + aggvoList.add(aggvo); + } + } + return aggvoList; + } + + private void pushToRZMOM(SaleOutVO[] saleOutVOS) throws BusinessException { + String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP"); + JSONObject jsonObject = new JSONObject(); + JSONObject data = new JSONObject(); + JSONObject dataIn = new JSONObject(); + JSONObject dataIn2 = new JSONObject(); + JSONArray details = new JSONArray(); + jsonObject.put("dataflow","̩BIPRZMOMv6"); + jsonObject.put("actionCode","cpfhtzdb"); + ///ϸ + for (SaleOutVO saleOutVO : saleOutVOS) { + SaleOutHeadVO head = saleOutVO.getHead(); + SaleOutBodyVO[] bodys = saleOutVO.getBodys(); + // Ҫͬ + buildSyncData(head, bodys,details); + } + dataIn2.put("Details",details); + dataIn.put("Data",dataIn2); + data.put("data",dataIn); + jsonObject.put("data",data); + log.error("۳ǩģ"+jsonObject.toJSONString()); + String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); + JSONObject resultObj = JSONObject.parseObject(result); + if("false".equals(resultObj.getString("success"))){ + throw new BusinessException("RZMOMͬʧܣԭ"+resultObj.getString("msg")); + } + } + + private void buildSyncData(SaleOutHeadVO head, SaleOutBodyVO[] bodys, JSONArray details) throws BusinessException { + + String vbillcode = head.getVbillcode();//ݺ + String vtrantypecode = head.getVtrantypecode();//ͱ + // + String cdptCode =transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE,DeptVO.PK_DEPT,head.getCdptid()); + + for(SaleOutBodyVO body:bodys){ + JSONObject singleObj = new JSONObject(); + String cgeneralhid = body.getCgeneralhid();//ͷ + String cgeneralbid = body.getCgeneralbid();// + String crowno = body.getCrowno();//к + String cmaterialvid = body.getCmaterialvid();// + String casscustid = body.getCasscustid();//ͻ + String cbodywarehouseid = body.getCbodywarehouseid();//ֿ + UFDate dbizdate = body.getDbizdate();//ֿ + singleObj.put("djbh_id",cgeneralhid+"_"+cgeneralbid);//id + singleObj.put("djbh",vbillcode);//ݱ + singleObj.put("djxh",crowno);// + singleObj.put("djrq",dbizdate.toString());//-- + singleObj.put("wbid",cgeneralhid);//ϵͳid + singleObj.put("wbpid",cgeneralbid);//ϵͳid + //ϵͳid-- + singleObj.put("wlbm_wbid",transferCodeByPk(MaterialVO.getDefaultTableName(),MaterialVO.CODE,MaterialVO.PK_MATERIAL,cmaterialvid)); + //ϵͳͻid-- + singleObj.put("khbh_wbid",transferCodeByPk(CustomerVO.getDefaultTableName(),CustomerVO.CODE,CustomerVO.PK_CUSTOMER,casscustid)); + //ʹص-code + String storeCode = transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, cbodywarehouseid); + singleObj.put("sddd",storeCode); + //ϵͳֿid -code + singleObj.put("ckbh_wbid",storeCode); + // + singleObj.put("bzsm",cdptCode); + //ǩ + singleObj.put("qfbj",1); + // + singleObj.put("ddbh",body.getVsourcebillcode()); + // + singleObj.put("ddxh",body.getVsourcerowno()); + // + singleObj.put("djsl",body.getNshouldassistnum().getDouble()); + //״̬ 1/޸ġ2ɾɾʱֻϴwbid + singleObj.put("operate",1); + details.add(singleObj); + } + } + + + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if(StringUtils.isEmpty(pk)){ + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + selectField); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(pkField, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } + +} diff --git a/uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java b/uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java new file mode 100644 index 0000000..0828fe3 --- /dev/null +++ b/uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java @@ -0,0 +1,68 @@ +package nc.bs.uapbd.util; + + +import nc.vo.pub.BusinessException; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +/** + * @Classname ThirdPartyPostRequestUtil + * @Description TODO + * @Version 1.0.0 + * @Date 2025/5/15 18:22 + * @Created by ame + */ +public class ThirdPartyPostRequestUtil { + + private static final int DEFAULT_CONNECT_TIMEOUT = 10000; + private static final int DEFAULT_READ_TIMEOUT = 10000; + + /** + * ϵͳ POST 󣬲 HTTP ״̬뷵 + * + * @param requestUrl ַ + * @param requestBody 壨JSON ʽ + * @return ӦΪ 200򷵻Ӧݣ򷵻شϢ + */ + public static String sendPostRequest(String requestUrl, String requestBody) throws BusinessException { + try { + URL url = new URL(requestUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + // 󷽷Ͳ + connection.setRequestMethod("POST"); + connection.setDoOutput(true); // + connection.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT); // ӳʱʱ + connection.setReadTimeout(DEFAULT_READ_TIMEOUT); // öȡʱʱ + connection.setRequestProperty("Content-Type", "application/json"); // ͷ + + // + try (OutputStream os = connection.getOutputStream()) { + byte[] input = requestBody.getBytes("utf-8"); + os.write(input, 0, input.length); + } + + // ȡӦ + int responseCode = connection.getResponseCode(); + + if (responseCode == HttpURLConnection.HTTP_OK) { // ɹӦ + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + StringBuilder responseBuilder = new StringBuilder(); + while ((line = in.readLine()) != null) { + responseBuilder.append(line); + } + in.close(); + return responseBuilder.toString(); // سɹӦ + } else { + throw new BusinessException("POST ʧܣӦ룺" + responseCode) ; // ʧϢ + } + } catch (Exception e) { + throw new BusinessException("쳣" + e.getMessage()) ; // 쳣 + } + } + +} From e1f46549b858ce90b5e14221de70d8dcb634f593 Mon Sep 17 00:00:00 2001 From: luo jia shan <125556714+Topfunplus@users.noreply.github.com> Date: Sat, 17 May 2025 16:26:07 +0800 Subject: [PATCH 05/16] =?UTF-8?q?feat(pu):=20=E9=87=87=E8=B4=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=AE=A1=E6=89=B9=E5=90=8E=E5=90=8C=E6=AD=A5=E5=88=B0?= =?UTF-8?q?=E7=9D=BF=E6=99=BA=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 AfterApprovingSynchronizeRuleRZ 类实现采购订单审批后同步到睿智系统 - 修改 OrderApproveAction 类,添加采购订单审批后的同步规则 - 更新 AfterApprovingSynchronizeRule 和 AfterSigningSynchronizeRule 类,调整组织过滤条件 --- .../rule/AfterSigningSynchronizeRule.java | 6 +- .../rule/AfterApprovingSynchronizeRule.java | 6 +- .../bs/pu/m21/action/OrderApproveAction.java | 133 ++++++++++++ .../AfterApprovingSynchronizeRuleRZ.java | 205 ++++++++++++++++++ 4 files changed, 346 insertions(+), 4 deletions(-) create mode 100644 pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java create mode 100644 pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java index 9909ce7..f475442 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java @@ -16,7 +16,9 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; -//۳⣨ǩֺMES˼άϵͳ +/** + * ۳⣨ǩֺMES˼άϵͳ + */ public class AfterSigningSynchronizeRule implements IRule { private static final String SALE_OUT_URL = "/GTHINKING/AjaxService/N_MISPRO/SaleOrderOutbound.ashx/SaveData"; // ۳Ǽǽӿ private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -59,7 +61,7 @@ public class AfterSigningSynchronizeRule implements IRule { */ private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) { obmlog.debug("AfterSigningSynchronizeRule-ʼ۳ⵥ: " + hvo.getVbillcode()); - if (!hvo.getPk_org().equals("0001A1100000000026O5") || !hvo.getPk_org().equals("1001A11000000KFE18FO")) { + if (!hvo.getPk_org().equals("0001A110000000000677")) { obmlog.debug("AfterSigningSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + hvo.getVbillcode()); return null; } diff --git a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java index e4f7a5e..984c808 100644 --- a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java @@ -18,7 +18,9 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; -// ̵㣨MES +/** + * ̵㣨MES + */ public class AfterApprovingSynchronizeRule implements IRule { private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/N_MISPRO/InvCount.ashx/SaveData"; // ̵㵥ͬӿ private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -65,7 +67,7 @@ public class AfterApprovingSynchronizeRule implements IRule { */ private JSONObject buildSyncData(InvCountHeaderVO hvo, InvCountBodyVO[] bvos) throws BusinessException { obmlog.debug("AfterApprovingSynchronizeRule-ʼ̵㵥: " + hvo.getVbillcode()); - if (!hvo.getPk_org().equals("0001A1100000000026O5") || !hvo.getPk_org().equals("1001A11000000KFE18FO")) { + if (!hvo.getPk_org().equals("0001A110000000000677")) { obmlog.debug("AfterApprovingSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + hvo.getVbillcode()); return null; } diff --git a/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java b/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java new file mode 100644 index 0000000..e139a9f --- /dev/null +++ b/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java @@ -0,0 +1,133 @@ +package nc.bs.pu.m21.action; + +import nc.bs.pu.m21.action.rule.approve.AfterApprovingSynchronizeRuleRZ; +import nc.bs.pu.m21.maintain.rule.SupplierFrozeChkRule; +import nc.bs.pu.m21.plugin.OrderPluginPoint; +import nc.bs.pub.compiler.AbstractCompiler2; +import nc.bs.scmpub.pf.PfParameterUtil; +import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; +import nc.impl.pu.m21.action.OrderReviseApproveAction; +import nc.impl.pu.m21.action.rule.approve.*; +import nc.impl.pu.m21.action.rule.pm.OrderApprovePMSupplyRule; +import nc.impl.pu.m21.action.rule.pm.OrderRewritePMStartDateRule; +import nc.impl.pu.m21.action.rule.revise.CheckBfinalcloseRule; +import nc.impl.pubapp.pattern.data.bill.BillUpdate; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +import nc.itf.pu.m21.compensate.IOrderSagasCompensate; +import nc.itf.pu.reference.ic.ATPServices; +import nc.vo.pu.m21.context.OrderContext; +import nc.vo.pu.m21.entity.OrderVO; +import nc.vo.pu.pub.enumeration.POEnumBillStatus; +import nc.vo.pu.pub.rule.pf.UpdatePflowVORule; +import nc.vo.pu.pub.sagas.PUSagasOperationEnum; +import nc.vo.pub.BusinessException; +import nc.vo.pub.compiler.PfParameterVO; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.scmpub.msg.rule.UpdateMsgStatusRule; +import nc.vo.scmpub.res.billtype.POBillType; +import nc.vo.scmpub.util.AppInfoContext; +import nccloud.commons.lang.ArrayUtils; +import nccloud.pubimpl.pu.mobile.service.order.MobAfterApproveForPoOrderImpl; +import nccloud.pubitf.pu.pub.util.PuSagasUtil; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class OrderApproveAction { + public OrderApproveAction() { + } + + public OrderVO[] approve(OrderVO[] vos, AbstractCompiler2 script, OrderContext[] ctxs) { + Integer reviseStatus = vos[0].getHVO().getRevisionStatus(); + PfParameterUtil util = new PfParameterUtil(script == null ? null : script.getPfParameterVO(), vos); + OrderVO[] originBills = (OrderVO[]) util.getClientOrignBills(); + OrderVO[] clientBills = (OrderVO[]) util.getClientFullInfoBill(); + AroundProcesser processer = new AroundProcesser(OrderPluginPoint.APPROVE); + this.addBeforeRule(processer); + this.addAfterRule(processer, null != script ? script.getPfParameterVO() : null); + OrderVO[] customProperty = (OrderVO[]) script.getPfParameterVO().getCustomProperty("nc.bs.scmpub.pf.ORIGIN_VO_PARAMETER"); + if (customProperty == null || customProperty.length == 0) { + clientBills = vos; + } + + processer.before(clientBills); + if (null != script) { + try { + script.procFlowBacth(script.getPfParameterVO()); + } catch (Exception e) { + ExceptionUtils.wrappException(e); + } + } + + OrderVO[] returnVos; + if (reviseStatus != null && reviseStatus == 0 && vos[0].getHVO().getForderstatus() == POEnumBillStatus.APPROVE.toIntValue()) { + OrderContext ctx = ArrayUtils.isEmpty(ctxs) ? new OrderContext() : ctxs[0]; + returnVos = (new OrderReviseApproveAction()).approve(clientBills, ctx); + } else { + this.atpBeforeUpdate(clientBills); + BillUpdate update = new BillUpdate(); + returnVos = (OrderVO[]) update.update(clientBills, originBills); + + try { + AppInfoContext.setProductCode(PUSagasOperationEnum.OREDERAPPROVE.getResCommon()); + AppInfoContext.setResId(PUSagasOperationEnum.OREDERAPPROVE.getResId()); + PuSagasUtil.frozenAndAddSaga(originBills, POBillType.Order.getCode()); + Map map = new HashMap(); + map.put("opertaion", "approve"); + map.put("pk_order", originBills[0].getHVO().getPk_order()); + map.put("po_order_isrevise", UFBoolean.FALSE); + map.put("po_orderapprover", originBills[0].getHVO().getApprover()); + map.put("po_ordertaudittime", originBills[0].getHVO().getTaudittime()); + map.put("po_orderforderstatus", originBills[0].getHVO().getForderstatus()); + PuSagasUtil.compensate(IOrderSagasCompensate.class, map); + } catch (BusinessException e) { + ExceptionUtils.wrappException(e); + } + + if (vos[0].getHVO().getForderstatus() == POEnumBillStatus.APPROVE.toIntValue()) { + this.atpUpdate(returnVos); + processer.after(returnVos); + } + } + + return returnVos; + } + + private void addAfterRule(AroundProcesser processer, PfParameterVO pfParameterVO) { + processer.addAfterRule(new ApproveBudgetCtrlRule()); + processer.addAfterRule(new FilterOrderByStatusRule(POEnumBillStatus.APPROVE.toInt())); + processer.addAfterRule(new ApproveSupplyRule()); + processer.addAfterRule(new InsertStatusOnWayRule()); + processer.addAfterRule(new InsertPayPlanBillVORule()); + processer.addAfterRule(new ApproveRewritePayPlanConfirmData4CTRule()); + processer.addAfterRule(new ApproveRewritePayPlanConfirmDataRule()); + processer.addAfterRule(new FillNcaninnumRule()); + processer.addAfterRule(new ApproveAfterEventRule()); + processer.addAfterRule(new MobAfterApproveForPoOrderImpl()); + processer.addAfterFinalRule(new UpdatePflowVORule(pfParameterVO)); + processer.addAfterFinalRule(new ApproveM21AndRewriteCTPayPlan()); + processer.addAfterRule(new OrderRewritePMStartDateRule(true)); + processer.addAfterRule(new OrderApprovePMSupplyRule()); + // ɹ ͬMESϵͳ + processer.addAfterRule(new AfterApprovingSynchronizeRuleRZ()); + } + + private void addBeforeRule(AroundProcesser processer) { + processer.addBeforeRule(new VOSagaFrozenValidateRule(true)); + processer.addBeforeRule(new CheckBfinalcloseRule()); + processer.addBeforeRule(new ApproveVOValidateRule()); + processer.addBeforeRule(new SupplierFrozeChkRule()); + processer.addBeforeRule(new ApproveBeforeEventRule()); + processer.addBeforeRule(new UpdateMsgStatusRule("pk_order")); + } + + private void atpBeforeUpdate(OrderVO[] vos) { + ATPServices.modifyATPBefore(POBillType.Order.getCode(), vos); + } + + private void atpUpdate(OrderVO[] vos) { + ATPServices.modifyATPAfter(POBillType.Order.getCode(), vos); + } +} diff --git a/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java new file mode 100644 index 0000000..aa178ce --- /dev/null +++ b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java @@ -0,0 +1,205 @@ +package nc.bs.pu.m21.action.rule.approve; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.dao.BaseDAO; +import nc.bs.logging.Log; +import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.pubitf.para.SysInitQuery; +import nc.vo.cmp.util.StringUtils; +import nc.vo.org.OrgVO; +import nc.vo.pu.m21.entity.OrderVO; +import nc.vo.pu.m21.entity.OrderHeaderVO; +import nc.vo.pu.m21.entity.OrderItemVO; +import nc.vo.pub.BusinessException; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.scmpub.util.ArrayUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * ɹͬϵͳ + */ +public class AfterApprovingSynchronizeRuleRZ implements IRule { + + private static final Log obmlog = Log.getInstance("rzmomlog"); + private static final BaseDAO dao = new BaseDAO(); + + private static final String DEFAULT_PURCHASE_TYPE = "ϲɹ"; + private static final int OPERATION_ADD = 1; + private static final int STATUS_LOCKED = 1; + private static final int STATUS_ISSUED = 1; + + @Override + public void process(OrderVO[] orderVOS) { + if (ArrayUtil.isEmpty(orderVOS)) { + return; + } + try { + //鲢ɸѡ۳ⵥΪ˾ + List newOrderVOS = checkAndFilterBillSrcOrg(orderVOS); + if (newOrderVOS.isEmpty()) { + return; + } + // ͵ϵͳ + pushToRZMOM(newOrderVOS.toArray(new OrderVO[0])); + } catch (Exception e) { + obmlog.error("ͬɹϵͳʧ: " + e.getMessage(), e); + ExceptionUtils.wrappException(e); + } + } + + private List checkAndFilterBillSrcOrg(OrderVO[] OrderVOS) throws BusinessException { + List aggvoList = new ArrayList<>(); + for (OrderVO aggvo : OrderVOS) { + String pkOrg = aggvo.getHVO().getPk_org(); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), pkOrg); + if ("30401".equals(orgCode)) { + aggvoList.add(aggvo); + } + } + return aggvoList; + } + + /** + * ݵMOMϵͳ + */ + private void pushToRZMOM(OrderVO[] orderVOS) throws BusinessException { + String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP"); + + JSONObject jsonObject = new JSONObject(); + // ͷ + jsonObject.put("dataflow", "̩BIPRZMOMv6"); + jsonObject.put("actionCode", "cghtb"); + + JSONObject dataIn = new JSONObject(); + JSONObject dataIn2 = new JSONObject(); + JSONArray details = new JSONArray(); + + // /ϸ + for (OrderVO orderVO : orderVOS) { + OrderHeaderVO head = orderVO.getHVO(); + OrderItemVO[] items = orderVO.getBVO(); + + // ͬ + buildSyncData(head, items, details); + } + + dataIn2.put("Details", details); + dataIn.put("Data", dataIn2); + jsonObject.put("data", dataIn); + + obmlog.error("ɹģ" + jsonObject.toJSONString()); + + // ʹThirdPartyPostRequestUtil + String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); + JSONObject resultObj = JSONObject.parseObject(result); + if ("false".equals(resultObj.getString("success"))) { + throw new BusinessException("RZMOMͬʧܣԭ" + resultObj.getString("msg")); + } + } + + /** + * ͬ + */ + private void buildSyncData(OrderHeaderVO head, OrderItemVO[] items, JSONArray details) { + if (items == null) { + return; + } + + for (OrderItemVO item : items) { + if (item == null) { + continue; + } + + JSONObject detailItem = new JSONObject(); + + // öϢ + detailItem.put("htmx_wbid", item.getPk_order_b()); + detailItem.put("cght_wbid", head.getVbillcode()); + detailItem.put("operate", OPERATION_ADD); + detailItem.put("zbxx_cglb_wbid", null); + detailItem.put("zbxx_cglx", DEFAULT_PURCHASE_TYPE); + + // Ϣ + if (head.getDbilldate() != null) { + detailItem.put("zbxx_cgrq", head.getDbilldate().toString()); + detailItem.put("cgrq", head.getDbilldate().toString()); + } + + // úͬϢ + detailItem.put("htxsbh", head.getVbillcode()); + detailItem.put("htxh", item.getCrowno()); + + // Ϣ + detailItem.put("wlbm_wbid", item.getPk_material()); + + // Ϣ + if (item.getNastnum() != null) { + detailItem.put("cgsl", item.getNastnum().doubleValue()); + } + + // ùӦ̺ͲɹԱϢ + detailItem.put("zbxx_gycs_wbid", head.getPk_supplier()); + detailItem.put("zbxx_cgy_wbid", head.getCemployeeid()); + + // øֱϢ + detailItem.put("zbxx_cgbz", null); + detailItem.put("zbxx_cslxr", null); + detailItem.put("zbxx_blbj", null); + detailItem.put("zbxx_hqbj", null); + detailItem.put("zbxx_hqsj", null); + detailItem.put("zbxx_dybj", null); + detailItem.put("zbxx_dysj", null); + detailItem.put("zbxx_httk", null); + detailItem.put("zbxx_cgyq", null); + detailItem.put("zbxx_fkfs", null); + + // üƻ + if (item.getDplanarrvdate() != null) { + detailItem.put("jhrq", item.getDplanarrvdate().toString()); + } + + // ԴϢ + detailItem.put("cgjh_wbid", item.getVsourcetrantype()); + detailItem.put("cgbh", item.getVsourcecode()); + detailItem.put("cgxh", item.getVsourcerowno()); + + // òֿͱעϢ + detailItem.put("sdck", item.getPk_reqstordoc()); + detailItem.put("bzsm", item.getVbmemo()); + + // ״̬Ϣ + detailItem.put("sdbj", STATUS_LOCKED); + detailItem.put("qfbj", STATUS_ISSUED); + + // õλϢ + detailItem.put("jldw", null); + + details.add(detailItem); + } + } + + /** + * ѯ + */ + private String transferCodeByPk(String tableName, String pk) throws BusinessException { + if (StringUtils.isEmpty(pk)) { + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + OrgVO.CODE); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(OrgVO.PK_ORG, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } +} From 61fe3c2d6bb1121c507c0c0eca208bdd8610b2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= <125556714+Topfunplus@users.noreply.github.com> Date: Sat, 17 May 2025 16:27:38 +0800 Subject: [PATCH 06/16] =?UTF-8?q?refactor(ic):=20=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=85=B6=E5=AE=83=E5=87=BA=E5=BA=93=E5=8D=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了对组织 ID 的判断条件,现在只同步山东泰开电缆有限公司的数据 - 优化了代码结构,提高了可读性 --- .../bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java index 39d1903..4396110 100644 --- a/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java +++ b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java @@ -44,10 +44,10 @@ public class AfterSignRuleSyncMesProcess implements IRule { private void syncOtherSystem(GeneralOutVO generalOutVO) throws BusinessException { obmlog.debug("ͬⵥ,ͱ:" + generalOutVO.getHead().getVtrantypecode() + "ʼƴ"); -// if (!generalOutVO.getHead().getPk_org().equals("0001A110000000000677")) { -// obmlog.debug("ͬɽ̩޹˾,ǰ֯:" + generalOutVO.getHead().getPk_org()); -// return; // ɽ̩޹˾ -// } + if (!generalOutVO.getHead().getPk_org().equals("0001A110000000000677")) { + obmlog.debug("ͬɽ̩޹˾,ǰ֯:" + generalOutVO.getHead().getPk_org()); + return; // ɽ̩޹˾ + } // if (generalOutVO.getHead().getVtrantypecode().equals("4I-01")) { From faa18d08c2b1e6c4fc69757ba4a2ab3a2102a079 Mon Sep 17 00:00:00 2001 From: maolei Date: Sat, 17 May 2025 17:42:59 +0800 Subject: [PATCH 07/16] =?UTF-8?q?feat(sc/m61,=20mmpac/pickm):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=A7=94=E5=A4=96=E8=AE=A2=E5=8D=95=E5=92=8C=E7=94=9F?= =?UTF-8?q?=E4=BA=A7bom=E5=AE=A1=E6=89=B9=E5=90=8E=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=87=B3RZMOM=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 AfterApproceRuleSyncRZWMSProcess 类实现销售出库单审批后同步至RZMOM - 新增 AfterApproveRuleSyncRZWMS 类实现生产领料单审批后同步至RZMOM - 新增 PickmApproveBP 类实现生产领料单批量审批 - 新增 SCOrderApproveAction 类实现销售订单审批 --- .../rule/AfterSignRuleSyncMesProcess.java | 4 +- .../nc/bs/mmpac/pickm/bp/PickmApproveBP.java | 55 +++++++ .../bp/rule/AfterApproveRuleSyncRZWMS.java | 127 ++++++++++++++++ .../pm/AfterApproceRuleSyncRZWMSProcess.java | 141 ++++++++++++++++++ .../action/approve/SCOrderApproveAction.java | 102 +++++++++++++ 5 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 mmpac/src/private/nc/bs/mmpac/pickm/bp/PickmApproveBP.java create mode 100644 mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java create mode 100644 sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java create mode 100644 sc/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java diff --git a/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java index 4396110..a21bda9 100644 --- a/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java +++ b/ic/src/private/nc/bs/ic/m4i/sign/rule/AfterSignRuleSyncMesProcess.java @@ -100,6 +100,8 @@ public class AfterSignRuleSyncMesProcess implements IRule { requestData.put("operation_type", "I");// ̶I requestData.put("info", info); obmlog.debug("requestData:" + requestData.toJSONString()); + IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + httpService.sendToExternalSystem("/GTHINKING/AjaxService/N_KCSJJS/101527004.ashx/gt_rec_api_qtckdj", requestData); } // /תⵥ if (generalOutVO.getHead().getVtrantypecode().equals("4I-02")) { @@ -167,7 +169,7 @@ public class AfterSignRuleSyncMesProcess implements IRule { obmlog.debug("requestData:" + requestData.toJSONString()); IHttpPostOtherSys httpService = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); - httpService.sendToExternalSystem("test", requestData); + httpService.sendToExternalSystem("/GTHINKING/AjaxService/N_KCSJJS/101527009.ashx/gt_rec_api_dbckdj", requestData); } } diff --git a/mmpac/src/private/nc/bs/mmpac/pickm/bp/PickmApproveBP.java b/mmpac/src/private/nc/bs/mmpac/pickm/bp/PickmApproveBP.java new file mode 100644 index 0000000..27a63fa --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pickm/bp/PickmApproveBP.java @@ -0,0 +1,55 @@ +package nc.bs.mmpac.pickm.bp; + + +import nc.bs.mmpac.pickm.plugin.PickmPluginPoint; +import nc.bs.mmpac.pickm.rule.PickmApproveCheckStatusRule; +import nc.bs.mmpac.pickm.rule.PickmCheckAuditRule; +import nc.bs.mmpac.pickm.rule.PickmFbackflustimeCheckRule; +import nc.bs.mmpac.pickm.rule.PickmSetStatusRule; +import nc.bs.mmpub.rule.MMATOMaterialCheckRule; +import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.data.bill.template.UpdateBPTemplate; +import nc.impl.pubapp.pattern.data.bill.tool.BillTransferTool; +import nc.impl.pubapp.pattern.rule.ICompareRule; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser; +import nc.util.mmf.framework.base.MMValueCheck; +import nc.vo.mmpac.pickm.entity.AggPickmVO; +import nc.vo.mmpac.pickm.enumeration.FbillstatusEnum; + +public class PickmApproveBP { + + private void addAfterRule(CompareAroundProcesser processer) { + } + + private void addBeforeRule(CompareAroundProcesser processer) { + ICompareRule pickmstatusFilterRule = new PickmApproveCheckStatusRule(true); + processer.addBeforeRule(pickmstatusFilterRule); + IRule sagasCheckrule = new MMVOSagaFrozenValidateRule(true); + processer.addBeforeRule(sagasCheckrule); + IRule pickmAuditCheckRule = new PickmCheckAuditRule(); + processer.addBeforeRule(pickmAuditCheckRule); + IRule mmatoMaterialCheckRule = new MMATOMaterialCheckRule("cmaterialvid", (String) null, "cffileid"); + processer.addBeforeRule(mmatoMaterialCheckRule); + IRule checkFbackFlusTime = new PickmFbackflustimeCheckRule(); + processer.addBeforeRule(checkFbackFlusTime); + IRule pickmSetStatusRule = new PickmSetStatusRule(FbillstatusEnum.AUDIT_STATE); + processer.addBeforeRule(pickmSetStatusRule); + } + + public AggPickmVO[] batchApprovePickm(AggPickmVO[] vos) { + if (MMValueCheck.isEmpty(vos)) { + return null; + } else { + UpdateBPTemplate bpTemplate = new UpdateBPTemplate(PickmPluginPoint.APPROVE); + BillTransferTool transTool = new BillTransferTool(vos); + this.addBeforeRule(bpTemplate.getAroundProcesser()); + this.addAfterRule(bpTemplate.getAroundProcesser()); + AggPickmVO[] fullBills = (AggPickmVO[]) transTool.getClientFullInfoBill(); + AggPickmVO[] originBills = (AggPickmVO[]) transTool.getOriginBills(); + AggPickmVO[] retBills = (AggPickmVO[]) bpTemplate.update(fullBills, originBills); + return retBills; + } + } + +} diff --git a/mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java b/mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java new file mode 100644 index 0000000..8fe32a5 --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java @@ -0,0 +1,127 @@ +package nc.bs.mmpac.pickm.bp.rule; + + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.dao.BaseDAO; +import nc.bs.logging.Log; +import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.pubitf.para.SysInitQuery; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.rt.rt0004.entity.RcVO; +import nc.vo.cmp.util.StringUtils; +import nc.vo.mmpac.pickm.entity.AggPickmVO; +import nc.vo.mmpac.pickm.entity.PickmHeadVO; +import nc.vo.mmpac.pickm.entity.PickmItemVO; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.scmpub.util.ArrayUtil; + +import java.util.ArrayList; +import java.util.List; + +public class AfterApproveRuleSyncRZWMS implements IRule { + + private static Log log = Log.getInstance("rzmomlog"); + + private static BaseDAO dao = new BaseDAO(); + + @Override + public void process(AggPickmVO[] vos) { + if (ArrayUtil.isEmpty(vos)) { + return; + } + try { + // 鲢ɸѡ֯ + List newAggPickmVOS = checkAndFilterBillSrcOrg(vos); + if (newAggPickmVOS.isEmpty()) { + return; + } + pushToRZMOM(newAggPickmVOS.toArray(new AggPickmVO[0])); + } catch (Exception e) { + ExceptionUtils.wrappException(e); + } + } + + private void buildSyncData(PickmHeadVO head, PickmItemVO[] bodys, JSONArray details) throws BusinessException { + for (PickmItemVO body : bodys) { + JSONObject singleObj = new JSONObject(); + String vsourcebillcode = head.getVsourcebillcode(); + String wlbm_wbid = transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getCbmaterialvid()); + String scgx_wbid = transferCodeByPk(RcVO.getDefaultTableName(), RcVO.VRCCODE, RcVO.CRCID, head.getVstdprocid()); + String wbid = vsourcebillcode + "_" + wlbm_wbid + "_" + scgx_wbid; + + singleObj.put("scgx_wbid", scgx_wbid); // ϵͳʹùid + singleObj.put("scjh_wbid", vsourcebillcode); // ϵͳƻID + singleObj.put("dwyl", body.getNplanoutastnum()); // λ + singleObj.put("djyl", body.getNplanoutastnum()); // + singleObj.put("clyl", body.getNplanoutastnum()); // + singleObj.put("wlbm_wbid", wlbm_wbid); // ϵͳid + singleObj.put("wbid", wbid); // ϵͳid + + details.add(singleObj); + + } + } + + private List checkAndFilterBillSrcOrg(AggPickmVO[] aggPickmVOS) throws BusinessException { + List aggvoList = new ArrayList<>(); + for (AggPickmVO aggvo : aggPickmVOS) { + String pkOrg = aggvo.getParentVO().getPk_org(); // ֯ڱͷ + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if ("30401".equals(orgCode)) { // ʾ֯ + aggvoList.add(aggvo); + } + } + return aggvoList; + } + + private void pushToRZMOM(AggPickmVO[] aggPickmVOS) throws BusinessException { + String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP"); + JSONObject jsonObject = new JSONObject(); + JSONObject data = new JSONObject(); + JSONObject dataIn = new JSONObject(); + JSONObject dataIn2 = new JSONObject(); + JSONArray details = new JSONArray(); + jsonObject.put("dataflow", "̩BIPRZMOMv6"); + jsonObject.put("actionCode", "cpfhtzdb"); + + for (AggPickmVO aggPickmVO : aggPickmVOS) { + PickmHeadVO head = aggPickmVO.getParentVO(); + PickmItemVO[] bodys = (PickmItemVO[]) aggPickmVO.getChildrenVO(); + buildSyncData(head, bodys, details); + } + dataIn2.put("Details", details); + dataIn.put("Data", dataIn2); + data.put("data", dataIn); + jsonObject.put("data", data); + log.error("BOWģ" + jsonObject.toJSONString()); + String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); + JSONObject resultObj = JSONObject.parseObject(result); + if (resultObj == null || !"true".equals(resultObj.getString("success"))) { + String errorMsg = resultObj == null ? "ӿڷΪ" : resultObj.getString("msg"); + throw new BusinessException("RZͬʧܣԭ" + errorMsg); + } + } + + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if (StringUtils.isEmpty(pk)) { + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + selectField); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(pkField, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } + +} diff --git a/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java b/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java new file mode 100644 index 0000000..bb8e7c5 --- /dev/null +++ b/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java @@ -0,0 +1,141 @@ +package nc.bs.sc.m61.referred.rule.pm; + + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.dao.BaseDAO; +import nc.bs.logging.Log; +import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.pubitf.para.SysInitQuery; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.psn.PsndocVO; +import nc.vo.bd.stordoc.StordocVO; +import nc.vo.bd.supplier.SupplierVO; +import nc.vo.cmp.util.StringUtils; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.sc.m61.entity.SCOrderHeaderVO; +import nc.vo.sc.m61.entity.SCOrderItemVO; +import nc.vo.sc.m61.entity.SCOrderVO; +import nc.vo.scmpub.util.ArrayUtil; + +import java.util.ArrayList; +import java.util.List; + +public class AfterApproceRuleSyncRZWMSProcess implements IRule { + + private static Log log = Log.getInstance("rzmomlog"); + + private static BaseDAO dao = new BaseDAO(); + + @Override + public void process(SCOrderVO[] vos) { + if (ArrayUtil.isEmpty(vos)) { + return; + } + try { + //鲢ɸѡ۳ⵥΪ˾ + List newSCOrderVOS = checkAndFilterBillSrcOrg(vos); + if (newSCOrderVOS == null || newSCOrderVOS.size() < 1) { + return; + } + pushToRZMOM(newSCOrderVOS.toArray(new SCOrderVO[0])); + } catch (Exception e) { + ExceptionUtils.wrappException(e); + } + } + + private void buildSyncData(SCOrderHeaderVO head, SCOrderItemVO[] bodys, JSONArray details) throws BusinessException { + + for (SCOrderItemVO body : bodys) { + JSONObject singleObj = new JSONObject(); + + // + singleObj.put("cgjh_wbid", body.getVsrctrantype()); + singleObj.put("cgxh", body.getVsrcrowno()); + singleObj.put("cgbh", body.getVsrccode()); + singleObj.put("bzsm", body.getVbmemo()); + singleObj.put("cght_wbid", head.getVbillcode()); + singleObj.put("htxsbh", head.getVbillcode()); + // Ӧ + singleObj.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, head.getPk_supplier())); + // ֿ + singleObj.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getPk_recvstordoc())); + // + singleObj.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getPk_material())); + + singleObj.put("cgsl", body.getNqtunitnum()); + singleObj.put("jhrq", body.getDplanarrvdate()); + singleObj.put("zbxx_cgrq", head.getDbilldate().toString()); + singleObj.put("cgrq", head.getDbilldate()).toString(); + + singleObj.put("htxh", body.getCrowno()); + // ҵԱ + singleObj.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, head.getCemployeeid())); + + details.add(singleObj); + } + } + + private List checkAndFilterBillSrcOrg(SCOrderVO[] SCOrderVOS) throws BusinessException { + List aggvoList = new ArrayList<>(); + for (SCOrderVO aggvo : SCOrderVOS) { + String pkOrg = aggvo.getParentVO().getPk_org(); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if ("30401".equals(orgCode)) { + aggvoList.add(aggvo); + } + } + return aggvoList; + } + + private void pushToRZMOM(SCOrderVO[] SCOrderVOS) throws BusinessException { + String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP"); + JSONObject jsonObject = new JSONObject(); + JSONObject data = new JSONObject(); + JSONObject dataIn = new JSONObject(); + JSONObject dataIn2 = new JSONObject(); + JSONArray details = new JSONArray(); + jsonObject.put("dataflow", "̩BIPRZMOMv6"); + jsonObject.put("actionCode", "cpfhtzdb"); + ///ϸ + for (SCOrderVO SCOrderVO : SCOrderVOS) { + SCOrderHeaderVO head = SCOrderVO.getParentVO(); + SCOrderItemVO[] bodys = SCOrderVO.getChildrenVO(); + // Ҫͬ + buildSyncData(head, bodys, details); + } + dataIn2.put("Details", details); + dataIn.put("Data", dataIn2); + data.put("data", dataIn); + jsonObject.put("data", data); + log.error("ίⶩģ" + jsonObject.toJSONString()); + String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); + JSONObject resultObj = JSONObject.parseObject(result); + if ("false".equals(resultObj.getString("success"))) { + throw new BusinessException("RZMOMͬʧܣԭ" + resultObj.getString("msg")); + } + } + + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if (StringUtils.isEmpty(pk)) { + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + selectField); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(pkField, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } + + +} diff --git a/sc/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java b/sc/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java new file mode 100644 index 0000000..6205993 --- /dev/null +++ b/sc/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java @@ -0,0 +1,102 @@ +package nc.impl.sc.m61.action.approve; + + +import nc.bs.pub.compiler.AbstractCompiler2; +import nc.bs.sc.m61.referred.rule.ic.ApproveSupplyRule; +import nc.bs.sc.m61.referred.rule.pm.AfterApproceRuleSyncRZWMSProcess; +import nc.bs.sc.m61.referred.rule.pm.SCOrderApprovePMSupplyRule; +import nc.bs.sc.m61.referred.rule.pm.SCOrderRewritePMStartDateRule; +import nc.bs.sc.plugin.SCOrderPluginPoint; +import nc.bs.scmpub.pf.PfParameterUtil; +import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.data.bill.BillUpdate; +import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser; +import nc.impl.sc.m61.action.approve.rule.*; +import nc.itf.sc.m61.compenstate.IScOrderPmSagasCompensate; +import nc.itf.sc.reference.ic.ATPServices; +import nc.vo.pub.BusinessException; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.sc.m61.entity.SCOrderVO; +import nc.vo.sc.m61.entity.context.SCOrderContxt; +import nc.vo.sc.pub.enumeration.SCBillStatus; +import nc.vo.scmpub.msg.rule.UpdateMsgStatusRule; +import nc.vo.scmpub.res.billtype.SCBillType; +import nc.vo.scmpub.util.AppInfoContext; +import nccloud.commons.lang.ArrayUtils; +import nccloud.pubitf.pu.pub.util.PuSagasUtil; +import nccloud.pubitf.sc.pub.util.SCOperationEnum; +import nccloud.pubitf.sc.pub.util.SCSagasOperationEnum; +import nccloud.pubitf.sc.pub.util.ScSagasUtil; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class SCOrderApproveAction { + + private void addRule(CompareAroundProcesser prcr) { + prcr.addBeforeRule(new VOSagaFrozenValidateRule(true)); + prcr.addBeforeFinalRule(new ApproveStatusChkRule()); + prcr.addBeforeFinalRule(new SupplierFrozeChkRule()); + prcr.addBeforeFinalRule(new UpdateMsgStatusRule("pk_order")); + prcr.addBeforeRule(new ApproveFlowCheckMnyRule()); + prcr.addAfterFinalRule(new UpdatePFlowInfoRule()); + prcr.addAfterRule(new FilterOrderByStatusRule(SCBillStatus.APPROVED.toInt())); + prcr.addAfterRule(new SCOrderRewritePMStartDateRule(true)); + prcr.addAfterRule(new ApproveSupplyRule()); + prcr.addAfterRule(new SCOrderApprovePMSupplyRule()); + prcr.addAfterRule(new AfterApproceRuleSyncRZWMSProcess()); + } + + public SCOrderVO[] approve(SCOrderVO[] vos, SCOrderContxt contxt, AbstractCompiler2 script) { + if (ArrayUtils.isEmpty(vos)) { + return vos; + } else { + PfParameterUtil util = new PfParameterUtil(script == null ? null : script.getPfParameterVO(), vos); + SCOrderVO[] originBills = (SCOrderVO[]) util.getOrginBills(); + SCOrderVO[] clientBills = (SCOrderVO[]) util.getClientFullInfoBill(); + CompareAroundProcesser prcr = new CompareAroundProcesser(SCOrderPluginPoint.APPROVE); + this.addRule(prcr); + prcr.before(clientBills, originBills); + if (null != script) { + try { + script.procFlowBacth(script.getPfParameterVO()); + } catch (Exception e) { + ExceptionUtils.wrappException(e); + } + } + + this.atpBeforeUpdate(clientBills); + + try { + AppInfoContext.setProductCode(SCSagasOperationEnum.OREDERAPPROVE.getResCommon()); + AppInfoContext.setResId(SCSagasOperationEnum.OREDERAPPROVE.getResId()); + ScSagasUtil.frozenAndAddSaga(vos, "scorderApprove", SCBillType.Order.getCode()); + Map paramMap = new HashMap(); + paramMap.put("actionname", "scorderApprove"); + paramMap.put("hid", originBills[0].getParentVO().getPrimaryKey()); + paramMap.put(SCOperationEnum.APPROVER, originBills[0].getParentVO().getApprover()); + paramMap.put(SCOperationEnum.TAUDITTIME, originBills[0].getParentVO().getTaudittime()); + paramMap.put(SCOperationEnum.FBILLSTATUS, originBills[0].getParentVO().getFstatusflag()); + PuSagasUtil.compensate(IScOrderPmSagasCompensate.class, paramMap); + } catch (BusinessException e) { + ExceptionUtils.wrappException(e); + } + + BillUpdate update = new BillUpdate(); + SCOrderVO[] updateVOs = (SCOrderVO[]) update.update(clientBills, originBills); + prcr.after(clientBills, originBills); + this.atpAfterUpdate(updateVOs); + return updateVOs; + } + } + + private void atpAfterUpdate(SCOrderVO[] updateVOs) { + ATPServices.modifyATPAfter(SCBillType.Order.getCode(), updateVOs); + } + + private void atpBeforeUpdate(SCOrderVO[] clientBills) { + ATPServices.modifyATPBefore(SCBillType.Order.getCode(), clientBills); + } + +} From a3d1f7bc697268f4c29b5883b14ee19d3d3682f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= <125556714+Topfunplus@users.noreply.github.com> Date: Sat, 17 May 2025 17:54:11 +0800 Subject: [PATCH 08/16] =?UTF-8?q?feat(mmpac):=20=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=AE=A1=E6=89=B9=E5=90=8E=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=88=B0=E7=9D=BF=E6=99=BA=E7=B3=BB=E7=BB=9F-=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20AfterApprovingSynchronizeRuleRZ=20=E7=B1=BB?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=AE=A1=E6=89=B9=E5=90=8E=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20-=20=E5=9C=A8=20PMOApproveBP=20=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E5=90=8C=E6=AD=A5=E8=A7=84=E5=88=99?= =?UTF-8?q?=E5=88=B0=E5=AE=A1=E6=89=B9=E6=B5=81=E7=A8=8B=20-=20=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E4=BA=86=E5=AF=B9=E7=89=B9=E5=AE=9A=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E7=9A=84=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E5=92=8C=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=20-=20=E9=80=9A=E8=BF=87=20HTTP=20=E8=AF=B7=E6=B1=82=E5=B0=86?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A8=E9=80=81=E5=88=B0=E7=9D=BF=E6=99=BA?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java | 81 ++++++++ .../rule/AfterApprovingSynchronizeRuleRZ.java | 194 ++++++++++++++++++ 2 files changed, 275 insertions(+) create mode 100644 mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java create mode 100644 mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java new file mode 100644 index 0000000..de3e335 --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java @@ -0,0 +1,81 @@ +package nc.bs.mmpac.pmo.pac0002.bp; + +import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterApprovingSynchronizeRuleRZ; +import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint; +import nc.bs.mmpac.pmo.pac0002.rule.*; +import nc.bs.mmpac.pmo.pac0002.rule.check.*; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillApproveValueRule; +import nc.bs.mmpac.pmo.pac0002.rule.psc.PMOCreatePSCPlanRule; +import nc.bs.mmpac.pmo.pac0002.rule.psc.PMOUnApproveCheckNscNumRule; +import nc.bs.mmpub.rule.MMATOMaterialCheckRule; +import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.rule.ICompareRule; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser; +import nc.util.mmf.framework.gc.GCUpdateBPTemplate; +import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; + +public class PMOApproveBP { + public PMOApproveBP() { + } + + public PMOAggVO[] approve(PMOAggVO[] fullBills, PMOAggVO[] originBills) { + GCUpdateBPTemplate bp = new GCUpdateBPTemplate(PMOPluginPoint.APPROVE); + this.addApproveBeforeRule(bp.getAroundProcesser()); + this.addApproveAfterRule(bp.getAroundProcesser()); + return (PMOAggVO[]) bp.update(fullBills, originBills); + } + + private void addApproveBeforeRule(CompareAroundProcesser processer) { + IRule checkFrozenRule = new MMVOSagaFrozenValidateRule(true); + processer.addBeforeRule(checkFrozenRule); + processer.addBeforeRule(new PMOCheckApproveStatusRule()); + IRule checkDeptRule = new PMOCheckDeptNotNullRule(); + processer.addBeforeRule(checkDeptRule); + IRule approvefillvaluerule = new PMOFillApproveValueRule(false); + processer.addBeforeRule(approvefillvaluerule); + IRule approvecheckrule = new PMOCheckProcedureNotNullRule(); + processer.addBeforeRule(approvecheckrule); + IRule operTypeRule = new PMOCheckApproveOperTypeRule(); + processer.addBeforeRule(operTypeRule); + IRule mmatoMaterialCheckRule = new MMATOMaterialCheckRule((String) null, "cmaterialvid", "cffileid"); + processer.addBeforeRule(mmatoMaterialCheckRule); + } + + private void addApproveAfterRule(CompareAroundProcesser processer) { + IRule pickmrule = new PMOInsertPickmRule(); + processer.addAfterRule(pickmrule); + processer.addAfterRule(new PMOAuditAutoAuditPickmRule()); + processer.addAfterRule(new PMOCreatePSCPlanRule()); + ICompareRule auditSupplyRule = new PMOApproveAuditSupplyRule(); + processer.addAfterRule(auditSupplyRule); + // ͵ϵͳ + processer.addAfterRule(new AfterApprovingSynchronizeRuleRZ()); + } + + public PMOAggVO[] approveCancel(PMOAggVO[] fullBills, PMOAggVO[] originBills) { + GCUpdateBPTemplate bp = new GCUpdateBPTemplate(PMOPluginPoint.UNAPPROVE); + this.addApproveCancelBeforeRule(bp.getAroundProcesser()); + this.addApproveCancelAfterRule(bp.getAroundProcesser()); + return (PMOAggVO[]) bp.update(fullBills, originBills); + } + + private void addApproveCancelBeforeRule(CompareAroundProcesser processer) { + IRule checkFrozenRule = new MMVOSagaFrozenValidateRule(true); + processer.addBeforeRule(checkFrozenRule); + processer.addBeforeRule(new PMOCheckUnApproveStatusRule()); + PMOUnApproveCheckNscNumRule checkNscNumRule = new PMOUnApproveCheckNscNumRule(); + processer.addBeforeRule(checkNscNumRule); + IRule cancelcheckrule = new PMOCheckApproveCancelRule(); + processer.addBeforeRule(cancelcheckrule); + IRule cancelCheckPutPlanStatusRule = new PMOApproveCancelCheckPutPlanStatusRule(); + processer.addBeforeRule(cancelCheckPutPlanStatusRule); + IRule approvefillvaluerule = new PMOFillApproveValueRule(true); + processer.addBeforeRule(approvefillvaluerule); + } + + private void addApproveCancelAfterRule(CompareAroundProcesser processer) { + ICompareRule auditSupplyRule = new PMOApproveUnAuditSupplyRule(); + processer.addAfterRule(auditSupplyRule); + } +} diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java new file mode 100644 index 0000000..80726f6 --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java @@ -0,0 +1,194 @@ +package nc.bs.mmpac.pmo.pac0002.bp.rule; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.dao.BaseDAO; +import nc.bs.logging.Log; +import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.pubitf.para.SysInitQuery; +import nc.vo.cmp.util.StringUtils; +import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; +import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO; +import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.scmpub.util.ArrayUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * + */ +public class AfterApprovingSynchronizeRuleRZ implements IRule { + private static final Log log = Log.getInstance("rzmomlog"); + private static final BaseDAO dao = new BaseDAO(); + + @Override + public void process(PMOAggVO[] pmoAggVOS) { + if (ArrayUtil.isEmpty(pmoAggVOS)) { + return; + } + try { + // 鲢ɸѡ + List filteredOrders = checkAndFilterBillSrcOrg(pmoAggVOS); + if (filteredOrders.isEmpty()) { + return; + } + + // ͵ϵͳ + pushToRZMOM(filteredOrders.toArray(new PMOAggVO[0])); + } catch (Exception e) { + log.error("ͬϵͳʧ: " + e.getMessage(), e); + ExceptionUtils.wrappException(e); + } + } + + /** + * 鲢ɸѡҪͬĵ + */ + private List checkAndFilterBillSrcOrg(PMOAggVO[] pmoAggVOS) throws BusinessException { + List aggvoList = new ArrayList<>(); + for (PMOAggVO aggvo : pmoAggVOS) { + String pkOrg = aggvo.getParentVO().getPk_org(); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), pkOrg); + if ("30401".equals(orgCode)) { + aggvoList.add(aggvo); + } + } + return aggvoList; + } + + /** + * ݵMOMϵͳ + */ + private void pushToRZMOM(PMOAggVO[] pmoAggVOS) throws BusinessException { + String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP"); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataflow", "̩BIPRZMOMv6"); + jsonObject.put("actionCode", "scdd"); // action code + + JSONObject dataIn = new JSONObject(); + JSONObject dataIn2 = new JSONObject(); + JSONArray details = new JSONArray(); + + // /ϸ + for (PMOAggVO pmoAggVO : pmoAggVOS) { + PMOHeadVO head = pmoAggVO.getParentVO(); + PMOItemVO[] bodys = pmoAggVO.getChildrenVO(); + + // Ҫͬ + buildSyncData(head, bodys, details); + } + + dataIn2.put("Details", details); + dataIn.put("Data", dataIn2); + jsonObject.put("data", dataIn); + + log.error("ģ" + jsonObject.toJSONString()); + + String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); + JSONObject resultObj = JSONObject.parseObject(result); + if ("false".equals(resultObj.getString("success"))) { + throw new BusinessException("RZMOMͬʧܣԭ" + resultObj.getString("msg")); + } + } + + /** + * ͬ + */ + private void buildSyncData(PMOHeadVO head, PMOItemVO[] bodys, JSONArray details) throws BusinessException { + String vbillcode = head.getVbillcode(); // ݺ + + for (PMOItemVO body : bodys) { + JSONObject detailItem = new JSONObject(); + + // ӳֶ + detailItem.put("jhmx_wbid", vbillcode); // ϵͳid + detailItem.put("scjh_wbid", vbillcode); // ƻID + detailItem.put("operate", 1); // ״̬1/޸ + detailItem.put("scbh", vbillcode); // ƻ + + // ƻţʹʵֵΪ1 + String rowno = body.getVrowno(); + detailItem.put("jhxh", StringUtils.isEmpty(rowno) ? 1 : Integer.parseInt(rowno)); + + // ϵͳƻid + detailItem.put("jhlb_wbid", head.getVtrantypecode()); + + // ϵͳƷID + detailItem.put("wlbm_wbid", body.getCmaterialvid()); + + // ƻ + if (body.getNmmastnum() != null) { + detailItem.put("jhsl", body.getNmmastnum().doubleValue()); + } + detailItem.put("jhlx", null); + // ƻԱ + detailItem.put("jhy_wbid", null); + + // - ƻ + if (body.getTplanstarttime() != null) { + detailItem.put("sxrq", body.getTplanstarttime().toString()); + } + + // - ƻ깤 + if (body.getTplanendtime() != null) { + detailItem.put("wcrq", body.getTplanendtime().toString()); + } + + // ע˵ + detailItem.put("bzsm", head.getVnote()); + + // ǩ - ״̬ + detailItem.put("qfbj", body.getFitemstatus()); + + // ʹص - ֿ + detailItem.put("sdck", body.getCinwarehouseid()); + + // Ŀ + detailItem.put("wlzdycs06", body.getVdef1()); + + // ̶ֵ + detailItem.put("zdscjhlyb", 1); // ԶɼƻԴ + detailItem.put("jhbhzdsc", 0); // ƻ + detailItem.put("bomsdbj", 1); // BOM + detailItem.put("bsbj", 1); // װBom + + // ֶӳ + detailItem.put("khbh_wbid", body.getCcustomerid()); // ϵͳͻid + detailItem.put("cjbz_wbid", body.getCdeptid()); // ϵͳ乤ID + + // ۶ + detailItem.put("xsdd_wbid", body.getVfirstid()); // ϵͳ۶ID + detailItem.put("ddbh", body.getVsalebillcode()); // + detailItem.put("ddxh", body.getVfirstrowno()); // + + details.add(detailItem); + } + } + + /** + * ѯ + */ + private String transferCodeByPk(String tableName, String pk) throws BusinessException { + if (StringUtils.isEmpty(pk)) { + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + OrgVO.CODE); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(OrgVO.PK_ORG, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } +} From 8f7a6a11a5da825b85910ef56344a8bc10ad356a Mon Sep 17 00:00:00 2001 From: maolei Date: Sun, 18 May 2025 14:35:25 +0800 Subject: [PATCH 09/16] =?UTF-8?q?sc/m61/mmpac:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=A7=94=E5=A4=96=E8=AE=A2=E5=8D=95=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 AfterApproceRuleSyncRZWMSProcess 类中的代码添加详细注释 -优化 AfterApproveRuleSyncRZWMS 类中的代码格式 -统一代码风格,提高可读性 --- .../bp/rule/AfterApproveRuleSyncRZWMS.java | 4 +-- .../pm/AfterApproceRuleSyncRZWMSProcess.java | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java b/mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java index 8fe32a5..7823486 100644 --- a/mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java +++ b/mmpac/src/private/nc/bs/mmpac/pickm/bp/rule/AfterApproveRuleSyncRZWMS.java @@ -71,9 +71,9 @@ public class AfterApproveRuleSyncRZWMS implements IRule { private List checkAndFilterBillSrcOrg(AggPickmVO[] aggPickmVOS) throws BusinessException { List aggvoList = new ArrayList<>(); for (AggPickmVO aggvo : aggPickmVOS) { - String pkOrg = aggvo.getParentVO().getPk_org(); // ֯ڱͷ + String pkOrg = aggvo.getParentVO().getPk_org(); String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); - if ("30401".equals(orgCode)) { // ʾ֯ + if ("30401".equals(orgCode)) { aggvoList.add(aggvo); } } diff --git a/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java b/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java index bb8e7c5..c78dcd2 100644 --- a/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java +++ b/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java @@ -55,27 +55,27 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule { JSONObject singleObj = new JSONObject(); // - singleObj.put("cgjh_wbid", body.getVsrctrantype()); - singleObj.put("cgxh", body.getVsrcrowno()); - singleObj.put("cgbh", body.getVsrccode()); - singleObj.put("bzsm", body.getVbmemo()); - singleObj.put("cght_wbid", head.getVbillcode()); - singleObj.put("htxsbh", head.getVbillcode()); + singleObj.put("cgjh_wbid", body.getVsrctrantype()); // ϵͳɹƻid + singleObj.put("cgxh", body.getVsrcrowno()); // ɹƻ + singleObj.put("cgbh", body.getVsrccode()); // ɹƻ + singleObj.put("bzsm", body.getVbmemo()); // ע˵ + singleObj.put("cght_wbid", head.getVbillcode()); // ϵͳͬID + singleObj.put("htxsbh", head.getVbillcode()); // ͬ // Ӧ - singleObj.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, head.getPk_supplier())); + singleObj.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, head.getPk_supplier())); // ϵͳid // ֿ - singleObj.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getPk_recvstordoc())); + singleObj.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getPk_recvstordoc())); // ʹֿ // - singleObj.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getPk_material())); + singleObj.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getPk_material())); // ϵͳid - singleObj.put("cgsl", body.getNqtunitnum()); - singleObj.put("jhrq", body.getDplanarrvdate()); - singleObj.put("zbxx_cgrq", head.getDbilldate().toString()); - singleObj.put("cgrq", head.getDbilldate()).toString(); + singleObj.put("cgsl", body.getNqtunitnum()); // ɹ + singleObj.put("jhrq", body.getDplanarrvdate()); // + singleObj.put("zbxx_cgrq", head.getDbilldate().toString()); // ɹ + singleObj.put("cgrq", head.getDbilldate()).toString(); // ɹ + + singleObj.put("htxh", body.getCrowno()); // ͬ + singleObj.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, head.getCemployeeid())); // ϵͳɹԱid - singleObj.put("htxh", body.getCrowno()); - // ҵԱ - singleObj.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, head.getCemployeeid())); details.add(singleObj); } From 73d5e0c732391e9fd541f565fe62025ac8796de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Sun, 18 May 2025 14:45:50 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95/?= =?UTF-8?q?=E9=94=80=E5=94=AE=E5=87=BA=E5=BA=93=E5=AE=A1=E6=89=B9=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=94=90=E5=88=B6=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rule/AfterSigningSynchronizeRuleRZ.java | 2 +- .../AfterApprovingSynchronizeRuleRZ.java | 84 ++++++++++--------- .../pu/m21/action/OrderApproveAction.java | 2 +- 3 files changed, 45 insertions(+), 43 deletions(-) rename pu/src/private/nc/{bs => impl}/pu/m21/action/OrderApproveAction.java (99%) diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java index 01ce6b2..52aad8a 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java @@ -109,7 +109,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule { String cmaterialvid = body.getCmaterialvid();// String casscustid = body.getCasscustid();//ͻ String cbodywarehouseid = body.getCbodywarehouseid();//ֿ - UFDate dbizdate = body.getDbizdate();//ֿ + UFDate dbizdate = body.getDbizdate();// singleObj.put("djbh_id",cgeneralhid+"_"+cgeneralbid);//id singleObj.put("djbh",vbillcode);//ݱ singleObj.put("djxh",crowno);// diff --git a/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java index aa178ce..243cfb5 100644 --- a/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java +++ b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java @@ -8,12 +8,18 @@ import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; import nc.impl.pubapp.pattern.rule.IRule; import nc.jdbc.framework.processor.ColumnProcessor; import nc.pubitf.para.SysInitQuery; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.psn.PsndocVO; +import nc.vo.bd.stordoc.StordocVO; +import nc.vo.bd.supplier.SupplierVO; import nc.vo.cmp.util.StringUtils; import nc.vo.org.OrgVO; import nc.vo.pu.m21.entity.OrderVO; import nc.vo.pu.m21.entity.OrderHeaderVO; import nc.vo.pu.m21.entity.OrderItemVO; import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFDate; +import nc.vo.pub.lang.UFDouble; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.pubapp.pattern.pub.SqlBuilder; import nc.vo.scmpub.util.ArrayUtil; @@ -21,15 +27,15 @@ import nc.vo.scmpub.util.ArrayUtil; import java.util.ArrayList; import java.util.List; +import static nccloud.openapi.ic.m4c.mapping.M4cFieldsEnum.cmaterialvid; + /** - * ɹͬϵͳ + * ɹͬϵͳ */ public class AfterApprovingSynchronizeRuleRZ implements IRule { - private static final Log obmlog = Log.getInstance("rzmomlog"); + private static Log log = Log.getInstance("rzmomlog"); private static final BaseDAO dao = new BaseDAO(); - - private static final String DEFAULT_PURCHASE_TYPE = "ϲɹ"; private static final int OPERATION_ADD = 1; private static final int STATUS_LOCKED = 1; private static final int STATUS_ISSUED = 1; @@ -48,7 +54,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { // ͵ϵͳ pushToRZMOM(newOrderVOS.toArray(new OrderVO[0])); } catch (Exception e) { - obmlog.error("ͬɹϵͳʧ: " + e.getMessage(), e); + log.error("ͬɹϵͳʧ: " + e.getMessage(), e); ExceptionUtils.wrappException(e); } } @@ -57,8 +63,9 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { List aggvoList = new ArrayList<>(); for (OrderVO aggvo : OrderVOS) { String pkOrg = aggvo.getHVO().getPk_org(); - String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), pkOrg); - if ("30401".equals(orgCode)) { + Integer forderstatus = aggvo.getHVO().getForderstatus(); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if ("30401".equals(orgCode)&& 3==forderstatus) { aggvoList.add(aggvo); } } @@ -74,7 +81,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { JSONObject jsonObject = new JSONObject(); // ͷ jsonObject.put("dataflow", "̩BIPRZMOMv6"); - jsonObject.put("actionCode", "cghtb"); + jsonObject.put("actionCode", "htmxb"); JSONObject dataIn = new JSONObject(); JSONObject dataIn2 = new JSONObject(); @@ -93,7 +100,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { dataIn.put("Data", dataIn2); jsonObject.put("data", dataIn); - obmlog.error("ɹģ" + jsonObject.toJSONString()); + log.error("ɹģ" + jsonObject.toJSONString()); // ʹThirdPartyPostRequestUtil String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); @@ -106,7 +113,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { /** * ͬ */ - private void buildSyncData(OrderHeaderVO head, OrderItemVO[] items, JSONArray details) { + private void buildSyncData(OrderHeaderVO head, OrderItemVO[] items, JSONArray details) throws BusinessException { if (items == null) { return; } @@ -117,60 +124,55 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { } JSONObject detailItem = new JSONObject(); - + UFDate dbilldate = item.getDbilldate(); // öϢ +// ϵͳid detailItem.put("htmx_wbid", item.getPk_order_b()); + //ϵͳͬID detailItem.put("cght_wbid", head.getVbillcode()); + //״̬ 1/޸ġ2ɾɾʱֻϴwbid detailItem.put("operate", OPERATION_ADD); - detailItem.put("zbxx_cglb_wbid", null); - detailItem.put("zbxx_cglx", DEFAULT_PURCHASE_TYPE); - // Ϣ - if (head.getDbilldate() != null) { - detailItem.put("zbxx_cgrq", head.getDbilldate().toString()); - detailItem.put("cgrq", head.getDbilldate().toString()); - } +// detailItem.put("zbxx_cglb_wbid", null); +// detailItem.put("zbxx_cglx", DEFAULT_PURCHASE_TYPE); // úͬϢ +// ͬ 磺ɹţ1001 detailItem.put("htxsbh", head.getVbillcode()); +// ͬ 磺ɹţ123 detailItem.put("htxh", item.getCrowno()); // Ϣ - detailItem.put("wlbm_wbid", item.getPk_material()); + detailItem.put("wlbm_wbid",transferCodeByPk(MaterialVO.getDefaultTableName(),MaterialVO.CODE,MaterialVO.PK_MATERIAL,item.getPk_material())); // Ϣ - if (item.getNastnum() != null) { - detailItem.put("cgsl", item.getNastnum().doubleValue()); + UFDouble nastnum = item.getNastnum()==null?UFDouble.ZERO_DBL:item.getNastnum(); + detailItem.put("cgsl", nastnum); + + //ɹ ϸеIJɹ + if (dbilldate != null) { + detailItem.put("cgrq", dbilldate.toString()); } - // ùӦ̺ͲɹԱϢ - detailItem.put("zbxx_gycs_wbid", head.getPk_supplier()); - detailItem.put("zbxx_cgy_wbid", head.getCemployeeid()); - - // øֱϢ - detailItem.put("zbxx_cgbz", null); - detailItem.put("zbxx_cslxr", null); - detailItem.put("zbxx_blbj", null); - detailItem.put("zbxx_hqbj", null); - detailItem.put("zbxx_hqsj", null); - detailItem.put("zbxx_dybj", null); - detailItem.put("zbxx_dysj", null); - detailItem.put("zbxx_httk", null); - detailItem.put("zbxx_cgyq", null); - detailItem.put("zbxx_fkfs", null); + detailItem.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(),SupplierVO.CODE,SupplierVO.PK_SUPPLIER,head.getPk_supplier())); + detailItem.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC,head.getCemployeeid())); // üƻ +// ϸеĽ if (item.getDplanarrvdate() != null) { detailItem.put("jhrq", item.getDplanarrvdate().toString()); } // ԴϢ + //ϵͳɹƻid detailItem.put("cgjh_wbid", item.getVsourcetrantype()); + //ɹƻ detailItem.put("cgbh", item.getVsourcecode()); + //ɹƻ detailItem.put("cgxh", item.getVsourcerowno()); // òֿͱעϢ - detailItem.put("sdck", item.getPk_reqstordoc()); + detailItem.put("sdck",transferCodeByPk(StordocVO.getDefaultTableName(),StordocVO.CODE, StordocVO.PK_STORDOC,item.getPk_reqstordoc())); detailItem.put("bzsm", item.getVbmemo()); // ״̬Ϣ @@ -187,15 +189,15 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { /** * ѯ */ - private String transferCodeByPk(String tableName, String pk) throws BusinessException { - if (StringUtils.isEmpty(pk)) { + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if(StringUtils.isEmpty(pk)){ return null; } SqlBuilder sqlBuilder = new SqlBuilder(); - sqlBuilder.append(" select " + OrgVO.CODE); + sqlBuilder.append(" select " + selectField); sqlBuilder.append(" from " + tableName); sqlBuilder.append(" where "); - sqlBuilder.append(OrgVO.PK_ORG, pk); + sqlBuilder.append(pkField, pk); Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); if (o == null) { throw new BusinessException("δѯϢsql" + sqlBuilder + ""); diff --git a/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java b/pu/src/private/nc/impl/pu/m21/action/OrderApproveAction.java similarity index 99% rename from pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java rename to pu/src/private/nc/impl/pu/m21/action/OrderApproveAction.java index e139a9f..141428f 100644 --- a/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java +++ b/pu/src/private/nc/impl/pu/m21/action/OrderApproveAction.java @@ -1,4 +1,4 @@ -package nc.bs.pu.m21.action; +package nc.impl.pu.m21.action; import nc.bs.pu.m21.action.rule.approve.AfterApprovingSynchronizeRuleRZ; import nc.bs.pu.m21.maintain.rule.SupplierFrozeChkRule; From 1f3d4f0bfd8d952b21d1496229603d9d43dbdef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Sun, 18 May 2025 14:52:34 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95/?= =?UTF-8?q?=E9=94=80=E5=94=AE=E5=87=BA=E5=BA=93=E5=AE=A1=E6=89=B9=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=94=90=E5=88=B6=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/rule/approve/AfterApprovingSynchronizeRuleRZ.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java index 243cfb5..dc86323 100644 --- a/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java +++ b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java @@ -147,7 +147,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { // Ϣ UFDouble nastnum = item.getNastnum()==null?UFDouble.ZERO_DBL:item.getNastnum(); - detailItem.put("cgsl", nastnum); + detailItem.put("cgsl", nastnum.getDouble()); //ɹ ϸеIJɹ if (dbilldate != null) { From 4612e2f19b6a618ee965a9777333a5def8218e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Sun, 18 May 2025 15:13:21 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E5=A7=94=E5=A4=96=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E5=90=8C=E6=AD=A5=E9=94=90=E5=88=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AfterApproceRuleSyncRZWMSProcess.java | 22 ++++++++++++++----- .../src/client}/SCOrderApproveAction.java | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) rename {sc/src/private/nc/bs/sc/m61/referred/rule/pm => arap/src/client}/AfterApproceRuleSyncRZWMSProcess.java (86%) rename {sc/src/private/nc/impl/sc/m61/action/approve => arap/src/client}/SCOrderApproveAction.java (98%) diff --git a/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java b/arap/src/client/AfterApproceRuleSyncRZWMSProcess.java similarity index 86% rename from sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java rename to arap/src/client/AfterApproceRuleSyncRZWMSProcess.java index c78dcd2..64ac1fc 100644 --- a/sc/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java +++ b/arap/src/client/AfterApproceRuleSyncRZWMSProcess.java @@ -16,6 +16,7 @@ import nc.vo.bd.supplier.SupplierVO; import nc.vo.cmp.util.StringUtils; import nc.vo.org.OrgVO; import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFDouble; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.pubapp.pattern.pub.SqlBuilder; import nc.vo.sc.m61.entity.SCOrderHeaderVO; @@ -53,7 +54,8 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule { for (SCOrderItemVO body : bodys) { JSONObject singleObj = new JSONObject(); - + //״̬ 1/޸ġ2ɾɾʱֻϴwbid + singleObj.put("operate", 1); // singleObj.put("cgjh_wbid", body.getVsrctrantype()); // ϵͳɹƻid singleObj.put("cgxh", body.getVsrcrowno()); // ɹƻ @@ -68,10 +70,17 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule { // singleObj.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getPk_material())); // ϵͳid - singleObj.put("cgsl", body.getNqtunitnum()); // ɹ - singleObj.put("jhrq", body.getDplanarrvdate()); // - singleObj.put("zbxx_cgrq", head.getDbilldate().toString()); // ɹ - singleObj.put("cgrq", head.getDbilldate()).toString(); // ɹ + UFDouble nqtunitnum = body.getNqtunitnum() == null ? UFDouble.ZERO_DBL : body.getNqtunitnum(); + singleObj.put("cgsl", nqtunitnum.getDouble()); // ɹ + if (body.getDplanarrvdate() != null) { + singleObj.put("jhrq", body.getDplanarrvdate().toString()); // + } + if (head.getDbilldate() != null) { + singleObj.put("zbxx_cgrq", head.getDbilldate().toString()); // ɹ + } + if (head.getDbilldate() != null) { + singleObj.put("cgrq", head.getDbilldate().toString()); // ɹ + } singleObj.put("htxh", body.getCrowno()); // ͬ singleObj.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, head.getCemployeeid())); // ϵͳɹԱid @@ -85,8 +94,9 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule { List aggvoList = new ArrayList<>(); for (SCOrderVO aggvo : SCOrderVOS) { String pkOrg = aggvo.getParentVO().getPk_org(); + Integer fstatusflag = aggvo.getParentVO().getFstatusflag(); String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); - if ("30401".equals(orgCode)) { + if ("30401".equals(orgCode) && 3 == fstatusflag) { aggvoList.add(aggvo); } } diff --git a/sc/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java b/arap/src/client/SCOrderApproveAction.java similarity index 98% rename from sc/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java rename to arap/src/client/SCOrderApproveAction.java index 6205993..4664bed 100644 --- a/sc/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java +++ b/arap/src/client/SCOrderApproveAction.java @@ -45,6 +45,8 @@ public class SCOrderApproveAction { prcr.addAfterRule(new SCOrderRewritePMStartDateRule(true)); prcr.addAfterRule(new ApproveSupplyRule()); prcr.addAfterRule(new SCOrderApprovePMSupplyRule()); + + //20255181512--ίⶩRZϵͳ prcr.addAfterRule(new AfterApproceRuleSyncRZWMSProcess()); } From 069da120aa91e0acc85bee7da783fd039f4011b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= <125556714+Topfunplus@users.noreply.github.com> Date: Sun, 18 May 2025 15:15:50 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BF=AE=E6=94=B9RZ=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E5=AD=97=E6=AE=B5=E6=98=A0=E5=B0=84?= =?UTF-8?q?,=E4=BF=AE=E6=94=B9MES=E7=B3=BB=E7=BB=9F=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=AD=97=E6=AE=B5=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ic/src/private/nc/bs/ic/m4c/sign/SignBP.java | 2 +- ...va => AfterSigningSynchronizeRuleMES.java} | 106 ++++++++++-------- .../nc/bs/ic/m4r/approve/ApproveBP.java | 4 +- ... => AfterApprovingSynchronizeRuleMES.java} | 59 ++++++---- .../bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java | 2 +- .../rule/AfterApprovingSynchronizeRuleRZ.java | 102 ++++++----------- 6 files changed, 139 insertions(+), 136 deletions(-) rename ic/src/private/nc/bs/ic/m4c/sign/rule/{AfterSigningSynchronizeRule.java => AfterSigningSynchronizeRuleMES.java} (65%) rename ic/src/private/nc/bs/ic/m4r/approve/rule/{AfterApprovingSynchronizeRule.java => AfterApprovingSynchronizeRuleMES.java} (75%) diff --git a/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java b/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java index 1d916a1..5756daa 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java @@ -51,7 +51,7 @@ public class SignBP implements ISignBP, ISignRuleProvider processor.addAfterRule(new SaleOutProceedsRuleCG()); processor.addAfterRule(new MobAfterSignMessageRule()); // ۳ ǩֺ ͬMES˼άϵͳ - processor.addAfterRule(new AfterSigningSynchronizeRule()); + processor.addAfterRule(new AfterSigningSynchronizeRuleMES()); // ̵㣨MES // ۳ ǩֺ ͬ diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleMES.java similarity index 65% rename from ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java rename to ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleMES.java index f475442..93bad7a 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleMES.java @@ -3,14 +3,24 @@ package nc.bs.ic.m4c.sign.rule; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.yonyou.cloud.utils.StringUtils; +import nc.bs.dao.BaseDAO; import nc.bs.framework.common.NCLocator; import nc.bs.logging.Log; import nc.impl.pubapp.pattern.rule.IRule; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.vo.bd.cust.CustomerVO; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.material.measdoc.MeasdocVO; +import nc.vo.bd.psn.PsndocVO; +import nc.vo.bd.rack.RackVO; +import nc.vo.bd.supplier.SupplierVO; import nc.vo.ic.m4c.entity.SaleOutBodyVO; import nc.vo.ic.m4c.entity.SaleOutHeadVO; import nc.vo.ic.m4c.entity.SaleOutVO; +import nc.vo.org.DeptVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDate; +import nc.vo.pubapp.pattern.pub.SqlBuilder; import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; @@ -19,13 +29,14 @@ import java.text.SimpleDateFormat; /** * ۳⣨ǩֺMES˼άϵͳ */ -public class AfterSigningSynchronizeRule implements IRule { +public class AfterSigningSynchronizeRuleMES implements IRule { private static final String SALE_OUT_URL = "/GTHINKING/AjaxService/N_MISPRO/SaleOrderOutbound.ashx/SaveData"; // ۳Ǽǽӿ private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static final String logginfo = "OALOG"; private static final Log obmlog = Log.getInstance(logginfo); + private static BaseDAO dao = new BaseDAO(); - public AfterSigningSynchronizeRule() { + public AfterSigningSynchronizeRuleMES() { } @Override @@ -59,7 +70,7 @@ public class AfterSigningSynchronizeRule implements IRule { * Ͻ˼άϵͳӿڹ淶 * NCC/YonBIPֶӳ䵽˼άϵͳֶ */ - private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) { + private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) throws BusinessException { obmlog.debug("AfterSigningSynchronizeRule-ʼ۳ⵥ: " + hvo.getVbillcode()); if (!hvo.getPk_org().equals("0001A110000000000677")) { obmlog.debug("AfterSigningSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + hvo.getVbillcode()); @@ -73,43 +84,33 @@ public class AfterSigningSynchronizeRule implements IRule { info.put("orderNo", hvo.getVbillcode()); // ID - ݺ(vbillcode) // ڸʽת UFDate dbilldate = hvo.getDbilldate(); - String billDateStr = dateTimeFormat.format(dbilldate.toDate()); - info.put("orderDate", billDateStr); // ᵥ - (dbilldate) - info.put("planDate", billDateStr); // ƻ - ʹͬĵ - info.put("actureDate", billDateStr); - // ɷʽܴ洢Զֶ - String genType = getStringValue(hvo.getVdef1()); - info.put("genType", null); // ɷʽ - ĬN - info.put("type", "XSCK"); // ĬXSCK - info.put("departmentId", hvo.getCdptvid()); // ID - (cdptvid) - info.put("storeId", hvo.getCwarehouseid()); // ֿID - ֿ(cwarehouseid) - // ĬΪ1 + info.put("orderDate", dbilldate.toString()); // ᵥ - (dbilldate) + info.put("planDate", dbilldate.toString()); // ƻ - ʹͬĵ + info.put("actureDate", dbilldate.toString()); + info.put("genType", null); + info.put("type", "XSCK"); + // ID - (cdptvid) + info.put("departmentId", transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, hvo.getCdptvid())); + // ֿID - ֿ(cwarehouseid) + info.put("storeId", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, hvo.getCwarehouseid())); + // TODO info.put("exRate", null); info.put("sType", "N"); // Ĭֵ info.put("billing", "Y"); // ߷ƱĬֵ info.put("billingBasis", "S"); // ƱĬֵ - - // ЧڿΪգܴ洢ֶλԶֶ - String effDateStr = getStringValue(hvo.getVdef2()); - if (StringUtils.isNotEmpty(effDateStr)) { - try { - UFDate effDate = new UFDate(effDateStr); - info.put("effDate", dateTimeFormat.format(effDate.toDate())); - } catch (Exception e) { - obmlog.error("Чڳ: " + e.getMessage()); - } - } - + info.put("effDate", null); info.put("consignStoreId", null); // ۲ֿID info.put("consignType", null); // info.put("operatorNo", null); // ˹ - Ƶ(billmaker) - info.put("operatorName", null); // - Զֶ - info.put("storeKeeper", hvo.getCwhsmanagerid()); // Ա - Ա(cwhsmanagerid) - info.put("cwhsmanagerid", hvo.getCwhsmanagerid()); // ԱID - Ա(cwhsmanagerid) - info.put("customId", hvo.getCcustomerid()); // ͻID - ͻ(ccustomerid) + info.put("operatorName", null); // + // Ա - Ա(cwhsmanagerid) + info.put("storeKeeper", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, hvo.getCwhsmanagerid())); + // ԱID - Ա(cwhsmanagerid) + info.put("cwhsmanagerid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, hvo.getCwhsmanagerid())); + // ͻID - ͻ(ccustomerid) + info.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, hvo.getCcustomerid())); info.put("mark", "Y"); // ɱ־Ĭֵ info.put("remark", hvo.getVnote()); // ע - ע(vnote) - // detailsϸ JSONArray details = new JSONArray(); if (bvos != null) { @@ -117,32 +118,32 @@ public class AfterSigningSynchronizeRule implements IRule { JSONObject detail = new JSONObject(); detail.put("orderNo", hvo.getVbillcode()); // ID - ݺ(vbillcode) detail.put("sequenceNum", bvo.getCrowno()); - // ԴϢ - ֵȷӳ detail.put("saleOrderNo", null); // SOID - Դݺ(vsourcebillcode) detail.put("saleSequenceNum", null); // SO - Դк(vsourcerowno) detail.put("allocationNum", null); // - - // - ʹȷֶ - detail.put("materialId", bvo.getCmaterialoid()); // ID - (cmaterialoid) - detail.put("unit", bvo.getCunitid()); // λ - λ(cunitid) - detail.put("productNum", null); // - Զֶ - - detail.put("storageId", bvo.getClocationid()); // λ - λ(clocationid) - detail.put("batchNum", bvo.getVbatchcode()); // - κ(vbatchcode) + // ID - (cmaterialoid) + detail.put("materialId", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, bvo.getCmaterialoid())); + // λ - λ(cunitid) + detail.put("unit", transferCodeByPk(MeasdocVO.getDefaultTableName(), MeasdocVO.CODE, MeasdocVO.PK_MEASDOC, bvo.getCunitid())); + detail.put("productNum", null); + // λ - λ(clocationid) + detail.put("storageId", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, bvo.getClocationid())); + // - κ(vbatchcode) + detail.put("batchNum", bvo.getVbatchcode()); detail.put("scaleFactor", bvo.getVchangerate()); - // Ӧʵ detail.put("issuedQty", bvo.getNshouldassistnum()); // Ӧ(nshouldassistnum) detail.put("mIssuedQty", bvo.getNshouldnum()); // Ӧ(nshouldnum) detail.put("actQry", bvo.getNassistnum()); // ʵ(nassistnum) detail.put("mActQry", bvo.getNnum()); // ʵ(nnum) detail.put("assistActQry", null); // ʵ(nassistnum) - // ͻϢ - detail.put("customId", getStringValue(bvo.getCasscustid())); // ͻID - ͻ(casscustid) + // ͻID - ͻ(casscustid) + detail.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); // ӦϢ - detail.put("supplierId", getStringValue(bvo.getCvendorid())); // ӦID - Ӧ(cvendorid) + // ӦID - Ӧ(cvendorid) + detail.put("supplierId", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); detail.put("color", null); // detail.put("manufactureDate", null); // (dproducedate) @@ -196,4 +197,21 @@ public class AfterSigningSynchronizeRule implements IRule { obmlog.error("AfterSigningSynchronizeRule-Ӧ쳣: " + e.getMessage(), e); } } + + + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if (nc.vo.cmp.util.StringUtils.isEmpty(pk)) { + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + selectField); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(pkField, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } } diff --git a/ic/src/private/nc/bs/ic/m4r/approve/ApproveBP.java b/ic/src/private/nc/bs/ic/m4r/approve/ApproveBP.java index edd4eda..6b43f9c 100644 --- a/ic/src/private/nc/bs/ic/m4r/approve/ApproveBP.java +++ b/ic/src/private/nc/bs/ic/m4r/approve/ApproveBP.java @@ -1,6 +1,6 @@ package nc.bs.ic.m4r.approve; -import nc.bs.ic.m4r.approve.rule.AfterApprovingSynchronizeRule; +import nc.bs.ic.m4r.approve.rule.AfterApprovingSynchronizeRuleMES; import nc.bs.ic.m4r.approve.rule.PushInOutBills; import nc.bs.ic.m4r.base.BPPluginPoint; import nc.bs.ic.m4r.insert.rule.InvcountDataCheck; @@ -23,7 +23,7 @@ public class ApproveBP implements IApproveBP, IApproveRuleProvid public void addApproveAfterRule(ICAroundProcesser processor) { processor.addAfterRule(new PushInOutBills()); // ̵㣨MES - processor.addAfterRule(new AfterApprovingSynchronizeRule()); + processor.addAfterRule(new AfterApprovingSynchronizeRuleMES()); } public void addApproveBeforeRule(ICAroundProcesser processor) { diff --git a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java similarity index 75% rename from ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java rename to ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java index 984c808..d5afcd1 100644 --- a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java @@ -4,15 +4,22 @@ package nc.bs.ic.m4r.approve.rule; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.yonyou.cloud.utils.StringUtils; +import nc.bs.dao.BaseDAO; import nc.bs.framework.common.NCLocator; import nc.bs.logging.Log; import nc.impl.pubapp.pattern.rule.IRule; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.vo.bd.cust.CustomerVO; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.rack.RackVO; +import nc.vo.bd.supplier.SupplierVO; import nc.vo.ic.m4r.entity.InvCountBillVO; import nc.vo.ic.m4r.entity.InvCountBodyVO; import nc.vo.ic.m4r.entity.InvCountHeaderVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDate; import nc.vo.pub.lang.UFDouble; +import nc.vo.pubapp.pattern.pub.SqlBuilder; import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; @@ -21,13 +28,14 @@ import java.text.SimpleDateFormat; /** * ̵㣨MES */ -public class AfterApprovingSynchronizeRule implements IRule { +public class AfterApprovingSynchronizeRuleMES implements IRule { private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/N_MISPRO/InvCount.ashx/SaveData"; // ̵㵥ͬӿ private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static final String logginfo = "OALOG"; private static final Log obmlog = Log.getInstance(logginfo); + private static final BaseDAO dao = new BaseDAO(); - public AfterApprovingSynchronizeRule() { + public AfterApprovingSynchronizeRuleMES() { } @Override @@ -107,29 +115,24 @@ public class AfterApprovingSynchronizeRule implements IRule { if (bvos != null) { for (InvCountBodyVO bvo : bvos) { JSONObject detail = new JSONObject(); - - // ֶ // - תΪ - detail.put("sequenceNum", bvo.getCrowno()); // (crowno) - - detail.put("materialId", getStringValue(bvo.getCmaterialvid())); // ID(cmaterialvid) - - detail.put("storageId", getStringValue(bvo.getClocationid())); // λ(clocationid) - - detail.put("batchNum", getStringValue(bvo.getVbatchcode())); // (vbatchcode) - - + detail.put("sequenceNum", bvo.getCrowno()); + // ID(cmaterialvid) - + detail.put("materialId", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.PK_MATERIAL, MaterialVO.CODE, bvo.getCmaterialvid())); + // λ(clocationid) - + detail.put("storageId", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, bvo.getClocationid())); + // (vbatchcode) - + detail.put("batchNum", getStringValue(bvo.getVbatchcode())); // ̴ - ʹʵ UFDouble countNum = bvo.getNcountnum(); - if (countNum != null) { - detail.put("panQty", countNum.doubleValue()); // ̴(ncountnum) - - } else { - throw new BusinessException("̴Ϊ"); - } - - detail.put("customId", getStringValue(bvo.getCasscustid())); // ͻID - detail.put("supplierId", getStringValue(bvo.getCvendorid())); // ӦID - + detail.put("panQty", countNum.doubleValue()); // ̴(ncountnum) - + // ͻID + detail.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); + // ӦID + detail.put("supplierId", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); // ڴ - detail.put("manufactureDate", null); // ûУnull + detail.put("manufactureDate", null); detail.put("color", null); - // װϢԶԣ detail.put("packLen", null); detail.put("packSize", null); @@ -182,4 +185,20 @@ public class AfterApprovingSynchronizeRule implements IRule { obmlog.error("AfterApprovingSynchronizeRule-Ӧ쳣: " + e.getMessage(), e); } } + + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if (nc.vo.cmp.util.StringUtils.isEmpty(pk)) { + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + selectField); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(pkField, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } } diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java index de3e335..943304d 100644 --- a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java @@ -49,7 +49,7 @@ public class PMOApproveBP { processer.addAfterRule(new PMOCreatePSCPlanRule()); ICompareRule auditSupplyRule = new PMOApproveAuditSupplyRule(); processer.addAfterRule(auditSupplyRule); - // ͵ϵͳ + // ͵RZϵͳ processer.addAfterRule(new AfterApprovingSynchronizeRuleRZ()); } diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java index 80726f6..90ae7a7 100644 --- a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterApprovingSynchronizeRuleRZ.java @@ -8,21 +8,25 @@ import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; import nc.impl.pubapp.pattern.rule.IRule; import nc.jdbc.framework.processor.ColumnProcessor; import nc.pubitf.para.SysInitQuery; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.stordoc.StordocVO; import nc.vo.cmp.util.StringUtils; import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO; import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; +import nc.vo.org.DeptVO; import nc.vo.org.OrgVO; import nc.vo.pub.BusinessException; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.rum.stocks.StocksVO; import nc.vo.scmpub.util.ArrayUtil; import java.util.ArrayList; import java.util.List; /** - * + * RZ */ public class AfterApprovingSynchronizeRuleRZ implements IRule { private static final Log log = Log.getInstance("rzmomlog"); @@ -40,10 +44,10 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { return; } - // ͵ϵͳ + // ͵RZϵͳ pushToRZMOM(filteredOrders.toArray(new PMOAggVO[0])); } catch (Exception e) { - log.error("ͬϵͳʧ: " + e.getMessage(), e); + log.error("ͬRZϵͳʧ: " + e.getMessage(), e); ExceptionUtils.wrappException(e); } } @@ -55,7 +59,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { List aggvoList = new ArrayList<>(); for (PMOAggVO aggvo : pmoAggVOS) { String pkOrg = aggvo.getParentVO().getPk_org(); - String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), pkOrg); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); if ("30401".equals(orgCode)) { aggvoList.add(aggvo); } @@ -64,14 +68,13 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { } /** - * ݵMOMϵͳ + * ݵRZMOMϵͳ */ private void pushToRZMOM(PMOAggVO[] pmoAggVOS) throws BusinessException { String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP"); - JSONObject jsonObject = new JSONObject(); jsonObject.put("dataflow", "̩BIPRZMOMv6"); - jsonObject.put("actionCode", "scdd"); // action code + jsonObject.put("actionCode", "jhxmb"); // action code JSONObject dataIn = new JSONObject(); JSONObject dataIn2 = new JSONObject(); @@ -107,68 +110,31 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { for (PMOItemVO body : bodys) { JSONObject detailItem = new JSONObject(); - - // ӳֶ - detailItem.put("jhmx_wbid", vbillcode); // ϵͳid - detailItem.put("scjh_wbid", vbillcode); // ƻID - detailItem.put("operate", 1); // ״̬1/޸ - detailItem.put("scbh", vbillcode); // ƻ - - // ƻţʹʵֵΪ1 - String rowno = body.getVrowno(); - detailItem.put("jhxh", StringUtils.isEmpty(rowno) ? 1 : Integer.parseInt(rowno)); - // ϵͳƻid detailItem.put("jhlb_wbid", head.getVtrantypecode()); - - // ϵͳƷID - detailItem.put("wlbm_wbid", body.getCmaterialvid()); - - // ƻ - if (body.getNmmastnum() != null) { - detailItem.put("jhsl", body.getNmmastnum().doubleValue()); - } - detailItem.put("jhlx", null); - // ƻԱ - detailItem.put("jhy_wbid", null); - - // - ƻ - if (body.getTplanstarttime() != null) { - detailItem.put("sxrq", body.getTplanstarttime().toString()); - } - - // - ƻ깤 - if (body.getTplanendtime() != null) { - detailItem.put("wcrq", body.getTplanendtime().toString()); - } - + // ϵͳƷID ID + detailItem.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getCmaterialvid())); + // Ԥƿ + detailItem.put("sxrq", body.getTplanstarttime().toString()); + // Ԥ깤 + detailItem.put("wcrq", body.getTplanendtime().toString()); + detailItem.put("gdbj", body.getFitemstatus()); + // ƻ + detailItem.put("jhsl", body.getNmmastnum().doubleValue()); + // ֿ + detailItem.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getCinwarehouseid())); + detailItem.put("wlzdycs01", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getCinwarehouseid())); + // ID + detailItem.put("scgc_wbid", transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, body.getCdeptid())); + // + detailItem.put("ddbh", body.getVsalebillcode()); + // + detailItem.put("khddh", null); + detailItem.put("ddxh", null); // ע˵ - detailItem.put("bzsm", head.getVnote()); - - // ǩ - ״̬ - detailItem.put("qfbj", body.getFitemstatus()); - - // ʹص - ֿ - detailItem.put("sdck", body.getCinwarehouseid()); - + detailItem.put("bzsm", body.getVnote()); // Ŀ - detailItem.put("wlzdycs06", body.getVdef1()); - - // ̶ֵ - detailItem.put("zdscjhlyb", 1); // ԶɼƻԴ - detailItem.put("jhbhzdsc", 0); // ƻ - detailItem.put("bomsdbj", 1); // BOM - detailItem.put("bsbj", 1); // װBom - - // ֶӳ - detailItem.put("khbh_wbid", body.getCcustomerid()); // ϵͳͻid - detailItem.put("cjbz_wbid", body.getCdeptid()); // ϵͳ乤ID - - // ۶ - detailItem.put("xsdd_wbid", body.getVfirstid()); // ϵͳ۶ID - detailItem.put("ddbh", body.getVsalebillcode()); // - detailItem.put("ddxh", body.getVfirstrowno()); // - + detailItem.put("htbz,wlzdycs06", body.getVdef1()); details.add(detailItem); } } @@ -176,15 +142,15 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { /** * ѯ */ - private String transferCodeByPk(String tableName, String pk) throws BusinessException { + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { if (StringUtils.isEmpty(pk)) { return null; } SqlBuilder sqlBuilder = new SqlBuilder(); - sqlBuilder.append(" select " + OrgVO.CODE); + sqlBuilder.append(" select " + selectField); sqlBuilder.append(" from " + tableName); sqlBuilder.append(" where "); - sqlBuilder.append(OrgVO.PK_ORG, pk); + sqlBuilder.append(pkField, pk); Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); if (o == null) { throw new BusinessException("δѯϢsql" + sqlBuilder + ""); From 89a5e01d928fbaff3773a40b13f23a641f38721d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Sun, 18 May 2025 15:16:37 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E5=A7=94=E5=A4=96=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E5=90=8C=E6=AD=A5=E9=94=90=E5=88=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96=5F=E6=8E=A5=E5=8F=A3=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arap/src/client/AfterApproceRuleSyncRZWMSProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arap/src/client/AfterApproceRuleSyncRZWMSProcess.java b/arap/src/client/AfterApproceRuleSyncRZWMSProcess.java index 64ac1fc..288284d 100644 --- a/arap/src/client/AfterApproceRuleSyncRZWMSProcess.java +++ b/arap/src/client/AfterApproceRuleSyncRZWMSProcess.java @@ -111,7 +111,7 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule { JSONObject dataIn2 = new JSONObject(); JSONArray details = new JSONArray(); jsonObject.put("dataflow", "̩BIPRZMOMv6"); - jsonObject.put("actionCode", "cpfhtzdb"); + jsonObject.put("actionCode", "htmxb"); ///ϸ for (SCOrderVO SCOrderVO : SCOrderVOS) { SCOrderHeaderVO head = SCOrderVO.getParentVO(); From aa04553939d27e3c6c99d3e0a912a0c2832c49a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Mon, 19 May 2025 08:49:22 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E5=A7=94=E5=A4=96=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E5=90=8C=E6=AD=A5=E9=94=90=E5=88=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96=5F=E8=B7=AF=E5=BE=84=E5=8F=98?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../referred/rule/pm}/AfterApproceRuleSyncRZWMSProcess.java | 0 .../nc/impl/sc/m61/action/approve}/SCOrderApproveAction.java | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) rename arap/src/{client => private/nc/bs/sc/m61/referred/rule/pm}/AfterApproceRuleSyncRZWMSProcess.java (100%) rename arap/src/{client => private/nc/impl/sc/m61/action/approve}/SCOrderApproveAction.java (99%) diff --git a/arap/src/client/AfterApproceRuleSyncRZWMSProcess.java b/arap/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java similarity index 100% rename from arap/src/client/AfterApproceRuleSyncRZWMSProcess.java rename to arap/src/private/nc/bs/sc/m61/referred/rule/pm/AfterApproceRuleSyncRZWMSProcess.java diff --git a/arap/src/client/SCOrderApproveAction.java b/arap/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java similarity index 99% rename from arap/src/client/SCOrderApproveAction.java rename to arap/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java index 4664bed..393e69c 100644 --- a/arap/src/client/SCOrderApproveAction.java +++ b/arap/src/private/nc/impl/sc/m61/action/approve/SCOrderApproveAction.java @@ -3,7 +3,6 @@ package nc.impl.sc.m61.action.approve; import nc.bs.pub.compiler.AbstractCompiler2; import nc.bs.sc.m61.referred.rule.ic.ApproveSupplyRule; -import nc.bs.sc.m61.referred.rule.pm.AfterApproceRuleSyncRZWMSProcess; import nc.bs.sc.m61.referred.rule.pm.SCOrderApprovePMSupplyRule; import nc.bs.sc.m61.referred.rule.pm.SCOrderRewritePMStartDateRule; import nc.bs.sc.plugin.SCOrderPluginPoint; @@ -27,7 +26,7 @@ import nccloud.pubitf.pu.pub.util.PuSagasUtil; import nccloud.pubitf.sc.pub.util.SCOperationEnum; import nccloud.pubitf.sc.pub.util.SCSagasOperationEnum; import nccloud.pubitf.sc.pub.util.ScSagasUtil; - +import nc.bs.sc.m61.referred.rule.pm.AfterApproceRuleSyncRZWMSProcess; import java.io.Serializable; import java.util.HashMap; import java.util.Map; From 2821eb9d68ffc18a3831ea0002d82fde270b5bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= <125556714+Topfunplus@users.noreply.github.com> Date: Mon, 19 May 2025 10:34:21 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=9B=98=E7=82=B9?= =?UTF-8?q?=E5=8D=95=E5=AE=A1=E6=89=B9=E5=90=8E=E5=90=8C=E6=AD=A5=20MES=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新盘点单同步接口 URL - 重新定义请求数据结构,按照新规范构建请求参数- 优化日期处理逻辑 - 添加仓库编码、部门编码等字段的处理 - 重构明细数组,增加序号转换、物料编码、货位等字段 - 添加盘存数量、盘盈数量、盘亏数量等计算字段 - 优化异常处理和日志记录 --- .../AfterApprovingSynchronizeRuleMES.java | 117 ++++++++++-------- 1 file changed, 66 insertions(+), 51 deletions(-) diff --git a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java index d5afcd1..e420d26 100644 --- a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java +++ b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRuleMES.java @@ -12,10 +12,12 @@ import nc.jdbc.framework.processor.ColumnProcessor; import nc.vo.bd.cust.CustomerVO; import nc.vo.bd.material.MaterialVO; import nc.vo.bd.rack.RackVO; +import nc.vo.bd.stordoc.StordocVO; import nc.vo.bd.supplier.SupplierVO; import nc.vo.ic.m4r.entity.InvCountBillVO; import nc.vo.ic.m4r.entity.InvCountBodyVO; import nc.vo.ic.m4r.entity.InvCountHeaderVO; +import nc.vo.org.DeptVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDate; import nc.vo.pub.lang.UFDouble; @@ -29,8 +31,7 @@ import java.text.SimpleDateFormat; * ̵㣨MES */ public class AfterApprovingSynchronizeRuleMES implements IRule { - private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/N_MISPRO/InvCount.ashx/SaveData"; // ̵㵥ͬӿ - private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/U20231172_N_XSSJJSA/102397009.ashx/KCPD_INSERT"; // ̵㵥ͬӿ private static final String logginfo = "OALOG"; private static final Log obmlog = Log.getInstance(logginfo); private static final BaseDAO dao = new BaseDAO(); @@ -79,72 +80,86 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { obmlog.debug("AfterApprovingSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + hvo.getVbillcode()); return null; } + + // ¹淶 JSONObject requestData = new JSONObject(); - // Ϊ - requestData.put("operation_type", "I"); - // info - սӿҪñֶ - JSONObject info = new JSONObject(); + // ̵Ϣ ̵㵥 ΪʱԶ + requestData.put("PDDH", null); - // ֶ - info.put("storeId", hvo.getCwarehouseid()); // ֿID(cwarehouseid) - - info.put("departmentId", hvo.getCdptvid()); // ID(cdptvid) - + // ȡֿ + String warehouseCode = transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, hvo.getCwarehouseid()); + requestData.put("CKID", warehouseCode); + + // ̵㲿ű + String deptCode = transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, hvo.getCdptvid()); + requestData.put("BMID", deptCode); + // ̵ + requestData.put("PDR", getStringValue(hvo.getCountoperator())); // ڴ - ̵ UFDate dcountdate = hvo.getDcountdate(); if (dcountdate != null) { - info.put("date", dateTimeFormat.format(dcountdate.toDate())); // ̵(dcountdate) - + requestData.put("PDRQ", dcountdate.toString()); // ̵ - } else { - // ̵Ϊգʹõ - UFDate dbilldate = hvo.getDbilldate(); - if (dbilldate != null) { - info.put("date", dateTimeFormat.format(dbilldate.toDate())); - } else { - // ӿҪֶαûʹõǰ - info.put("date", dateTimeFormat.format(new java.util.Date())); - } + requestData.put("PDRQ", null); } + // ע + requestData.put("BZ", getStringValue(hvo.getVnote())); - // ֶ - info.put("worker", getStringValue(hvo.getCountoperator())); // ̵(countoperator) - info.put("mark", "N"); // ɱ־ĬΪN - info.put("remark", getStringValue(hvo.getVnote())); // ע(vnote) - - // detailsϸ + // ϸ JSONArray details = new JSONArray(); if (bvos != null) { for (InvCountBodyVO bvo : bvos) { JSONObject detail = new JSONObject(); - // - תΪ - detail.put("sequenceNum", bvo.getCrowno()); - // ID(cmaterialvid) - - detail.put("materialId", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.PK_MATERIAL, MaterialVO.CODE, bvo.getCmaterialvid())); - // λ(clocationid) - - detail.put("storageId", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, bvo.getClocationid())); - // (vbatchcode) - - detail.put("batchNum", getStringValue(bvo.getVbatchcode())); - // ̴ - ʹʵ - UFDouble countNum = bvo.getNcountnum(); - detail.put("panQty", countNum.doubleValue()); // ̴(ncountnum) - - // ͻID - detail.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); - // ӦID - detail.put("supplierId", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); - // ڴ - detail.put("manufactureDate", null); - detail.put("color", null); - // װϢԶԣ - detail.put("packLen", null); - detail.put("packSize", null); - // ע - detail.put("remark", getStringValue(bvo.getVnotebody())); // ע(vnotebody) + // ȡŲתΪ + String crownStr = bvo.getCrowno(); + try { + detail.put("XH", Double.parseDouble(crownStr)); // - + } catch (NumberFormatException e) { + detail.put("XH", null); // Ĭ + } + // ϱ - + detail.put("WLID", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, bvo.getCmaterialvid())); + // λ + detail.put("KW", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, bvo.getClocationid())); + // + detail.put("WLPH", getStringValue(bvo.getVbatchcode())); + + // ̴ -> ʵ + UFDouble pcNum = bvo.getNcountnum(); + // + UFDouble zmNum = bvo.getNonhandnum(); + if (pcNum != null) { + // ̴ -> ʵ + detail.put("PCSL", pcNum.getDouble()); + if (zmNum != null) { + // ӯ -> - ʵ + detail.put("PYSL", zmNum.getDouble() - pcNum.getDouble()); + // ̿ -> ʵ - + detail.put("PKSL", pcNum.getDouble() - zmNum.getDouble()); + } else { + detail.put("PYSL", null); + detail.put("PKSL", null); + } + } else { + detail.put("PCSL", null); + detail.put("PYSL", null); + detail.put("PKSL", null); + } + // ӯ + detail.put("YCDJ", null); + // ӯԭ + detail.put("YKYY", getStringValue(bvo.getVnotebody())); + // ͻ + detail.put("KHID", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); + // Ӧ̱ + detail.put("GYSID", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); + details.add(detail); } } - info.put("details", details); - - // infoӵ - requestData.put("info", info); + requestData.put("DETAILS", details); return requestData; }