From a80ef84abeda69be26a23c28b725ab3ee9bb6da2 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 12:02:10 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E9=94=90=E5=88=B6=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uapbd/doc/锐制基础数据视图.md | 157 ++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 uapbd/doc/锐制基础数据视图.md diff --git a/uapbd/doc/锐制基础数据视图.md b/uapbd/doc/锐制基础数据视图.md new file mode 100644 index 0000000..bb32f71 --- /dev/null +++ b/uapbd/doc/锐制基础数据视图.md @@ -0,0 +1,157 @@ +## ϱ +~~~sql +CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_MATERIAL" ("PK_MATERIAL", "CODE", "NAME", "MATERIALSPEC", "PK_MEASDOC", "CHKFREEFLAG", "ENABLESTATE", "PK_STORDOC", "MATERSTATE", "PK_ORG", "ORG_CODE", "TS") AS + SELECT DISTINCT + m.PK_MATERIAL, + m.CODE, + m.NAME, + m.MATERIALSPEC, + m.PK_MEASDOC, + mk.chkfreeflag, + m.ENABLESTATE, + mk.pk_stordoc, + md.materstate, + m.PK_ORG, + oo.code AS org_code, + GREATEST(m.TS, mk.TS, md.TS, oo.TS) AS TS +FROM + bd_material m + LEFT JOIN bd_materialstock mk ON m.PK_MATERIAL = mk.pk_material + LEFT JOIN bd_materialprod md ON m.PK_MATERIAL = md.pk_material + LEFT JOIN org_orgs oo ON m.pk_org = oo.pk_org +WHERE + m.dr = 0; +~~~ + +## Ϸ +~~~sql +CREATE VIEW V_UAPBD_QUERYSYNC_MATERIALCLASS as + SELECT + m.code, + m.name, + m.pk_marbasclass , + p.name AS parent_name, + p.code AS parent_code, + oo.CODE AS org_code, + p.pk_marbasclass pk_parent, + GREATEST(p.TS, m.TS, oo.TS) AS TS +FROM + bd_marbasclass m + LEFT JOIN bd_marbasclass p ON m.pk_parent = p.pk_marbasclass + LEFT JOIN ORG_ORGS oo ON m.PK_ORG = oo.PK_ORG +WHERE + m.dr = 0 +~~~ + +## Ա +~~~sql +CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_PSNDOC" ("PK_PSNDOC", "CODE", "NAME", "DEPT_CODE", "DEPT_NAME", "ENABLESTATE", "ORG_CODE", "TS") AS + SELECT + p.pk_psndoc, + p.CODE, + p.NAME, + dept.code AS dept_code, + dept.name AS dept_name, + p.ENABLESTATE, + org.code as org_code, + GREATEST(p.TS, j.TS,org.TS,dept.TS) AS TS +FROM + bd_psndoc p + LEFT JOIN bd_psnjob j ON p.pk_psndoc = j.pk_psndoc + AND j.ismainjob = 'Y' + AND j.dr = 0 + LEFT JOIN org_orgs org ON p.pk_org = org.pk_org + LEFT JOIN org_dept dept ON j.pk_dept = dept.pk_dept + -- LEFT JOIN org_group grp ON p.pk_group = grp.pk_group + -- LEFT JOIN bd_psncl cl ON j.pk_psncl = cl.pk_psncl + -- LEFT JOIN om_job job ON j.pk_job = job.pk_job + -- LEFT JOIN OM_POST post ON j.pk_post = post.pk_post +WHERE + p.dr = 0; +~~~ + +## ͻ +~~~sql +CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_CUSTOMER" ("PK_CUSTOMER", "NAME", "CODE", "ENABLESTATE", "SHORTNAME", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS + SELECT + c.pk_customer, + c.name, + c.code, + c.enablestate, + c.shortname, + oo.code AS org_code, + oo.name AS org_name, + og.code AS group_code, + og.name AS group_name, + GREATEST(c.ts, oo.TS, og.TS) AS TS +FROM + bd_customer c + LEFT JOIN org_orgs oo ON c.pk_org = oo.pk_org + LEFT JOIN org_group og ON c.pk_group = og.pk_group +WHERE + c.dr = 0; +~~~ + +## Ӧ +~~~sql +CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_SUPPLIER" ("CODE", "PK_SUPPLIER", "NAME", "ENABLESTATE", "SHORTNAME", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS + SELECT + s."CODE", + s."PK_SUPPLIER", + s."NAME", + s."ENABLESTATE", + s.shortname, + oo.code AS org_code, + oo.name AS org_name, + og.code AS group_code, + og.name AS group_name, + GREATEST(s.ts, oo.TS, og.TS) AS TS +FROM + bd_supplier s + LEFT JOIN org_orgs oo ON s.pk_org = oo.pk_org + LEFT JOIN org_group og ON s.pk_group = og.pk_group +WHERE + s.dr = 0; +~~~ + +## +~~~sql +CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_DEPT" ("CODE", "ENABLESTATE", "NAME", "PK_DEPT", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS + SELECT + d.CODE, + d.ENABLESTATE, + d.NAME, + d.PK_DEPT, + oo.code AS org_code, + oo.name AS org_name, + og.code AS group_code, + og.name AS group_name, + GREATEST(d.ts, oo.TS, og.TS) AS TS +FROM + org_dept d + LEFT JOIN org_orgs oo ON d.pk_org = oo.pk_org + LEFT JOIN org_group og ON d.pk_group = og.pk_group +WHERE + d.dr = 0; +~~~ + +## ֿ +~~~sql +CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_STORDOC" ("CODE", "ENABLESTATE", "PK_STORDOC", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS + SELECT + sd.CODE", + sd.ENABLESTATE, + sd.PK_STORDOC, + so.code AS org_code, + so.name AS org_name, + og.code AS group_code, + og.name AS group_name, + GREATEST(sd.ts, so.TS, og.TS) AS TS + +FROM + bd_stordoc sd + LEFT JOIN org_stockorg so ON sd.pk_org = so.pk_stockorg + LEFT JOIN org_group og ON sd.pk_group = og.pk_group +WHERE + sd.dr = 0; +~~~ \ No newline at end of file From 3679368e1c4fd7bc72095d830613885e04581a13 Mon Sep 17 00:00:00 2001 From: "zhangxinah@yonyou.com" Date: Mon, 19 May 2025 14:36:54 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E5=8D=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A6=82=E6=9E=9C=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=A2=AB=E5=88=A0=E9=99=A4=E5=90=8E=E7=BB=99=E5=87=BA=E6=98=8E?= =?UTF-8?q?=E7=A1=AE=E6=8F=90=E7=A4=BA-=E5=BC=A0=E9=91=AB0519?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nc/api/arap/resource/GatheringbillRestResource.java | 5 ++++- 1 file changed, 4 insertions(+), 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 ffbb5bd..2b21399 100644 --- a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java +++ b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java @@ -138,7 +138,7 @@ public class GatheringbillRestResource extends ArapBaseRestResource { Object tr = dao.executeQuery( "select ntaxrate from so_saleorder_b where csaleorderid = '" + csaleorderid + "'", new ColumnProcessor()); - //ntaxrate = new UFDouble(tr.toString()); + // ntaxrate = new UFDouble(tr.toString()); // ˰ Object ctaxcodeid = hybo.findColValue("so_saleorder_b", "ctaxcodeid", "csaleorderid = '" + csaleorderid + "' "); @@ -271,6 +271,9 @@ public class GatheringbillRestResource extends ArapBaseRestResource { HYSuperDMO dmo = new HYSuperDMO(); SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class, "vbillcode='" + def2 + "' and dr=0"); + if (hvo == null || hvo.length == 0) { + throw new BusinessException("۶ERPбɾţ" + def2); + } SaleOrderBVO[] bvos = (SaleOrderBVO[]) dmo.queryByWhereClause(SaleOrderBVO.class, "csaleorderid='" + hvo[0].getPrimaryKey() + "'"); if (bvos != null) { From fa093b84adf248554dd8a7202bba923ced596eaa 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 15:23:12 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E6=BA=90=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nccloud/openapi/mmpac/wr/WrResource.java | 569 ++++++++++++++++++ 1 file changed, 569 insertions(+) create mode 100644 mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java diff --git a/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java b/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java new file mode 100644 index 0000000..a460f9d --- /dev/null +++ b/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java @@ -0,0 +1,569 @@ +package nccloud.openapi.mmpac.wr; + +import nc.bs.dao.BaseDAO; +import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Log; +import nc.bs.uif2.validation.ValidationFailure; +import nc.util.mmf.framework.base.MMArrayUtil; +import nc.util.mmf.framework.base.MMCollectionUtil; +import nc.util.mmf.framework.base.MMNumberUtil; +import nc.util.mmf.framework.base.MMValueCheck; +import nc.vo.mmpac.wr.entity.AggWrVO; +import nc.vo.mmpac.wr.entity.WrItemVO; +import nc.vo.mmpac.wr.entity.WrQualityVO; +import nc.vo.mmpac.wr.entity.WrSerialNoVO; +import nc.vo.mmpac.wr.entity.WrVO; +import nc.vo.mmpac.wr.enumeration.WrBillStatusEnum; +import nc.vo.pub.BusinessException; +import nc.vo.pub.VOStatus; +import nc.vo.pub.billtype.BilltypeVO; +import nc.vo.pub.lang.UFDate; +import nc.vo.pubapp.AppContext; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nccloud.api.mmpac.wr.IAPIWrMaintain; +import nccloud.api.rest.utils.NCCRestUtils; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.openapi.scmpub.pub.TransferCodeToPKTool; +import nccloud.ws.rest.resource.AbstractNCCRestResource; +import org.json.JSONString; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +@Path("mmpac/wr") +public class WrResource extends AbstractNCCRestResource { + + private static String HEADTABLE = "mm_wr"; + + private static String BODYTABLE = "mm_wr_product"; + + private static String QUALITYTABLE = "mm_wr_quality"; + + private static String SERIALNOTABLE = "mm_wr_serialno"; + + private static String PICKNOTABLE = "mm_wr_pick"; + + private static String GNUM_QUALITY = "ngqualitynum"; + private static String GNUM_REWORK = "ngreworknum"; + private static String GNUM_REJECT = "ngrejectnum"; + private static String GASTNUM_QUALITY = "ngqualityastnum"; + private static String GASTNUM_REWORK = "ngreworkastnum"; + private static String GASTNUM_REJECT = "ngrejectastnum"; + private static List HeadUnUpdateFiled = Arrays.asList(WrVO.PK_WR, WrVO.PK_GROUP, WrVO.CWKID, + WrVO.FBILLSTATUS, WrVO.VBILLCODE, WrVO.PK_ORG, WrVO.PK_ORG_V); + private static List BodyUnUpdateFiled = Arrays.asList(WrItemVO.PK_WR, "cbunitid", "pk_group", "pk_org", + "pk_org_v", "pk_wr_product", "bbhasfbill", "bbhaspicked", "bbinstock", "bbisempass", "cbempass_bid", + "cbempass_brow", "cbempasscode", "cbempassid", "cbfirstmobid", "cbfirstmoid", "cbsrctranstype", "cbsrcmoid", + "cbsrcmobid", "cbfirstranstype", "cbmaterialid", "cbmainmaterialid", "fbsourcetype", "nbaldempinastnum", + "nbaldempinnum", "nbcheckastnum", "nbchecknum", "nbempassastnum", "nbempassnum", "nbsldcheckastnum", + "nbsldchecknum", "nbsldinastnum", "nbsldinnum", "vbbatchid", "vbfirstcode", "vbfirstid", "vbfirstmocode", + "vbfirstmorowno", "vbfirstranstype", "vbfirstrowid", "vbfirstrowno", "vbfirsttype", "vbidentify", + "vbinbatchid", "vbmainidentify", "vbmainmorowno", "vbmobillcode", "vbmoparentbillcode", "vbmorowno", + "vbparentmorowno", "vbsalebillcode", "vbsalebillid", "vbsrccode", "vbsrcid", "vbsrcmocode", "vbsrcmorowno", + "vbsrcrowid", "vbsrcrowno", "vbmainbomcode", "vbsrctranstype", "bbhasbckfled", "bbhaspicked", "bbsetmark"); + + @POST + @Path("saveAndApprove") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString saveAndApprove(List> paramList) { + if (MMValueCheck.isEmpty(paramList)) { + return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); + } + List voList = new ArrayList(); + try { + for (Map paramMap : paramList) { + if (!paramMap.containsKey(HEADTABLE) || !paramMap.containsKey(BODYTABLE)) { + return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); + } + Map headInfo = (Map) paramMap.get(HEADTABLE); + List> itemInfos = new ArrayList>(); + if (paramMap.get(BODYTABLE) instanceof List) { + itemInfos = (List>) paramMap.get(BODYTABLE); + } else { + Map bodyInfo = (Map) paramMap.get(BODYTABLE); + itemInfos.add(bodyInfo); + } + AggWrVO vo = new AggWrVO(); + WrVO head = new WrVO(); + head.setPk_group(AppContext.getInstance().getPkGroup()); + head.setStatus(VOStatus.NEW); + for (String key : headInfo.keySet()) { + head.setAttributeValue(key, headInfo.get(key)); + } + vo.setParentVO(head); + List items = new ArrayList(); + String paramdata = NCCRestUtils.toJSONString(itemInfos).toJSONString(); + Log.getInstance("mm-mes").info("mes" + paramdata); + for (Map itemMap : itemInfos) { + WrItemVO item = new WrItemVO(); + item.setStatus(VOStatus.NEW); + boolean hasGNumFlag = false; + for (String key : itemMap.keySet()) { + if (QUALITYTABLE.equals(key)) { + List> qualityInfos = (List>) itemMap + .get(QUALITYTABLE); + List qualitys = this.getWrQualitys(qualityInfos); + item.setQualityvos(qualitys.toArray(new WrQualityVO[0])); + } else if (SERIALNOTABLE.equals(key)) { + List> snInfos = (List>) itemMap.get(SERIALNOTABLE); + List snVOs = this.getWrSerialNos(snInfos); + item.setSerialnovos(snVOs.toArray(new WrSerialNoVO[0])); + } else if (PICKNOTABLE.equals(key)) { + continue; + } else if (this.isGNumFilds(key)) { + hasGNumFlag = true; + } else { + item.setAttributeValue(key, itemMap.get(key)); + } + } + if (hasGNumFlag) { + List qualitys = this.getWrQualitysByGnum(itemMap, item); + item.setQualityvos(qualitys.toArray(new WrQualityVO[0])); + } + items.add(item); + } + vo.setChildren(WrItemVO.class, items.toArray(new WrItemVO[0])); + voList.add(vo); + IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class); + AggWrVO[] aggvos = server.saveAndApprove(voList.toArray(new AggWrVO[0])); + boolean successFlag = true; + StringBuilder errMsg = new StringBuilder(); + if (MMArrayUtil.isNotEmpty(aggvos)) { + for (AggWrVO aggvo : aggvos) { + List validateList = aggvo.getParentVO().getExcpMsgList(); + if (MMCollectionUtil.isNotEmpty(validateList)) { + successFlag = false; + errMsg.append(aggvo.getParentVO().getVbillcode()); + errMsg.append(":"); + for (ValidationFailure validate : validateList) { + errMsg.append(validate.getMessage()); + errMsg.append(";"); + } + } + } + } + if (successFlag) { + return ResultMessageUtil.toJSON(aggvos, "汣ɹ"); + } else { + ExceptionUtils.wrappBusinessException(errMsg.toString()); + } + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return null; + } + + private List getWrQualitysByGnum(Map itemMap, WrItemVO item) { + List qualityVOs = new ArrayList(); + // ϸ1 + if (itemMap.containsKey(WrResource.GNUM_QUALITY) || itemMap.containsKey(WrResource.GASTNUM_QUALITY)) { + WrQualityVO qVO = new WrQualityVO(); + qVO.setFgprocessmethod(1); + if (itemMap.containsKey(WrResource.GNUM_QUALITY)) { + qVO.setAttributeValue(WrQualityVO.NGNUM, itemMap.get(WrResource.GNUM_QUALITY)); + } + if (itemMap.containsKey(WrResource.GASTNUM_QUALITY)) { + qVO.setAttributeValue(WrQualityVO.NGASTNUM, itemMap.get(WrResource.GASTNUM_QUALITY)); + } + if (MMNumberUtil.isGtZero(qVO.getNgnum()) || MMNumberUtil.isGtZero(qVO.getNgastnum())) { + qualityVOs.add(qVO); + } + } + // 2 + if (itemMap.containsKey(WrResource.GNUM_REJECT) || itemMap.containsKey(WrResource.GASTNUM_REJECT)) { + WrQualityVO qVO = new WrQualityVO(); + qVO.setFgprocessmethod(2); + if (itemMap.containsKey(WrResource.GNUM_REJECT)) { + qVO.setAttributeValue(WrQualityVO.NGNUM, itemMap.get(WrResource.GNUM_REJECT)); + } + if (itemMap.containsKey(WrResource.GASTNUM_REJECT)) { + qVO.setAttributeValue(WrQualityVO.NGASTNUM, itemMap.get(WrResource.GASTNUM_REJECT)); + } + if (MMNumberUtil.isGtZero(qVO.getNgnum()) || MMNumberUtil.isGtZero(qVO.getNgastnum())) { + qualityVOs.add(qVO); + } + } + // 3 + if (itemMap.containsKey(WrResource.GNUM_REWORK) || itemMap.containsKey(WrResource.GASTNUM_REWORK)) { + WrQualityVO qVO = new WrQualityVO(); + qVO.setFgprocessmethod(3); + if (itemMap.containsKey(WrResource.GNUM_REWORK)) { + qVO.setAttributeValue(WrQualityVO.NGNUM, itemMap.get(WrResource.GNUM_REWORK)); + } + if (itemMap.containsKey(WrResource.GASTNUM_REWORK)) { + qVO.setAttributeValue(WrQualityVO.NGASTNUM, itemMap.get(WrResource.GASTNUM_REWORK)); + } + if (MMNumberUtil.isGtZero(qVO.getNgnum()) || MMNumberUtil.isGtZero(qVO.getNgastnum())) { + qualityVOs.add(qVO); + } + } + return qualityVOs; + } + + private boolean isGNumFilds(String key) { + if (WrResource.GNUM_QUALITY.equals(key)) { + return true; + } else if (WrResource.GASTNUM_QUALITY.equals(key)) { + return true; + } else if (WrResource.GNUM_REJECT.equals(key)) { + return true; + } else if (WrResource.GASTNUM_REJECT.equals(key)) { + return true; + } else if (WrResource.GNUM_REWORK.equals(key)) { + return true; + } else if (WrResource.GASTNUM_REWORK.equals(key)) { + return true; + } + return false; + } + + private List getWrSerialNos(List> snInfos) { + List snVOs = new ArrayList(); + for (Map snInfo : snInfos) { + WrSerialNoVO snVO = new WrSerialNoVO(); + for (String key : snInfo.keySet()) { + snVO.setAttributeValue(key, snInfo.get(key)); + } + snVOs.add(snVO); + } + return snVOs; + } + + private List getWrQualitys(List> qualityInfos) { + List qualityVOs = new ArrayList(); + for (Map qualityInfo : qualityInfos) { + WrQualityVO qualityVO = new WrQualityVO(); + for (String key : qualityInfo.keySet()) { + qualityVO.setAttributeValue(key, qualityInfo.get(key)); + } + qualityVOs.add(qualityVO); + } + return qualityVOs; + } + + @Override + public String getModule() { + // TODO Auto-generated method stub + return null; + } + + @POST + @Path("deleteByMesIDs") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString deleteByMesIDs(String[] mesIDs) { + if (MMValueCheck.isEmpty(mesIDs)) { + return ResultMessageUtil.exceptionToJSON("쳣", "1"); + } + try { + IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class); + server.deleteWrByMesID(mesIDs); + return ResultMessageUtil.toJSON(null, "ɾɹ"); + + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + @POST + @Path("newsave") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString newsave(Map paramsMap) { + List> paramList = (List>) paramsMap.get("data"); + if (MMValueCheck.isEmpty(paramList)) { + return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); + } + List voList = new ArrayList(); + try { + for (Map paramMap : paramList) { + if (!paramMap.containsKey(HEADTABLE) || !paramMap.containsKey(BODYTABLE)) { + return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); + } + Map headInfo = (Map) paramMap.get(HEADTABLE); + List> itemInfos = new ArrayList>(); + if (paramMap.get(BODYTABLE) instanceof List) { + itemInfos = (List>) paramMap.get(BODYTABLE); + } else { + Map bodyInfo = (Map) paramMap.get(BODYTABLE); + itemInfos.add(bodyInfo); + } + AggWrVO vo = new AggWrVO(); + WrVO head = new WrVO(); + head.setPk_group(AppContext.getInstance().getPkGroup()); + for (String key : headInfo.keySet()) { + if (MMValueCheck.isEmpty(headInfo.get(key))) { + continue; + } + head.setAttributeValue(key, headInfo.get(key)); + } + vo.setParentVO(head); + List items = new ArrayList(); + String paramdata = NCCRestUtils.toJSONString(itemInfos).toJSONString(); + Log.getInstance("mm-mes").info("mes" + paramdata); + for (Map itemMap : itemInfos) { + WrItemVO item = new WrItemVO(); + boolean hasGNumFlag = false; + for (String key : itemMap.keySet()) { + + if (QUALITYTABLE.equals(key)) { + List> qualityInfos = (List>) itemMap + .get(QUALITYTABLE); + List qualitys = this.getWrQualitys(qualityInfos); + item.setQualityvos(qualitys.toArray(new WrQualityVO[0])); + } else if (SERIALNOTABLE.equals(key)) { + List> snInfos = (List>) itemMap.get(SERIALNOTABLE); + List snVOs = this.getWrSerialNos(snInfos); + item.setSerialnovos(snVOs.toArray(new WrSerialNoVO[0])); + } else if (PICKNOTABLE.equals(key)) { + continue; + } else if (this.isGNumFilds(key)) { + hasGNumFlag = true; + } else { + if (MMValueCheck.isEmpty(itemMap.get(key))) { + continue; + } + item.setAttributeValue(key, itemMap.get(key)); + } + } + if (hasGNumFlag) { + List qualitys = this.getWrQualitysByGnum(itemMap, item); + item.setQualityvos(qualitys.toArray(new WrQualityVO[0])); + } + items.add(item); + } + vo.setChildren(WrItemVO.class, items.toArray(new WrItemVO[0])); + voList.add(vo); + IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class); +// List aggWrVOS = TransferCodeToPKTool.transferAggVO(voList); +// //뱨 +// List collection = (List) new BaseDAO().retrieveByClause(BilltypeVO.class, " pk_billtypecode='" + aggWrVOS.get(0).getParentVO().getVtrantypecode()+"'"); +// aggWrVOS.get(0).getParentVO().setVtrantypeid(collection.get(0).getPk_billtypeid()); +// aggWrVOS.get(0).getParentVO().setDbilldate(new UFDate()); +// AggWrVO[] aggvos = server.newsave(aggWrVOS.toArray(new AggWrVO[0])); + AggWrVO[] aggvos = server.newsave(voList.toArray(new AggWrVO[0])); + boolean successFlag = true; + StringBuilder errMsg = new StringBuilder(); + if (MMArrayUtil.isNotEmpty(aggvos)) { + for (AggWrVO aggvo : aggvos) { + List validateList = aggvo.getParentVO().getExcpMsgList(); + if (MMCollectionUtil.isNotEmpty(validateList)) { + successFlag = false; + errMsg.append(aggvo.getParentVO().getVbillcode()); + errMsg.append(":"); + for (ValidationFailure validate : validateList) { + errMsg.append(validate.getMessage()); + errMsg.append(";"); + } + } + } + } + if (successFlag) { + return ResultMessageUtil.toJSON(aggvos, "汣ɹ"); + } else { + ExceptionUtils.wrappBusinessException(errMsg.toString()); + } + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return null; + } + + @POST + @Path("update") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString update(Map paramsMap) throws BusinessException { + List> paramList = (List>) paramsMap.get("data"); + if (MMValueCheck.isEmpty(paramList)) { + return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); + } + List voList = new ArrayList(); + IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class); + + List aggIds = new ArrayList<>(); + for (Map paramMap : paramList) { + if (!paramMap.containsKey(HEADTABLE) || !paramMap.containsKey(BODYTABLE)) { + return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); + } + Map headInfo = (Map) paramMap.get(HEADTABLE); + if (MMValueCheck.isNotEmpty(headInfo.get("pk_wr"))) { + aggIds.add(headInfo.get("pk_wr").toString()); + } + } + if (MMValueCheck.isEmpty(aggIds)) { + return ResultMessageUtil.exceptionToJSON("쳣Ҫͷ", "1"); + } + AggWrVO[] aggWrVOSByIds = server.findAggWrVOSByIds(aggIds.toArray(new String[0])); + Map voMap = new HashMap<>(); + for (AggWrVO aggWrVO : aggWrVOSByIds) { + voMap.put(aggWrVO.getParentVO().getPk_wr(), aggWrVO); + } + + try { + // ݴݲ޸ + for (Map paramMap : paramList) { + + Map headInfo = (Map) paramMap.get(HEADTABLE); + List> itemInfos = new ArrayList>(); + if (paramMap.get(BODYTABLE) instanceof List) { + itemInfos = (List>) paramMap.get(BODYTABLE); + } else { + Map bodyInfo = (Map) paramMap.get(BODYTABLE); + itemInfos.add(bodyInfo); + } + AggWrVO vo = voMap.get(headInfo.get("pk_wr").toString()); + if (MMValueCheck.isEmpty(vo)) { + return ResultMessageUtil + .exceptionToJSON("ݺţ" + headInfo.get("vbillcode") + "ݿвڻѾɾ", "1"); + } + WrVO head = vo.getParentVO(); + if (!(WrBillStatusEnum.I_FREEDOM.intValue() == head.getFbillstatus())) { + return ResultMessageUtil.exceptionToJSON("̬治޸ģ", "1"); + } + + // ͷ + head.setStatus(VOStatus.UPDATED); + for (String key : headInfo.keySet()) { + if (MMValueCheck.isEmpty(headInfo.get(key))) { + continue; + } + if (HeadUnUpdateFiled.contains(key) + && !head.getAttributeValue(key).toString().equals(headInfo.get(key))) { + return ResultMessageUtil.exceptionToJSON("ͷԣ" + key + "޸", "1"); + } + head.setAttributeValue(key, headInfo.get(key)); + } + vo.setParentVO(head); + + // ݺ + Map wrItemVOMap = new HashMap<>(); + if (MMValueCheck.isNotEmpty(vo.getChildrenVO())) { + for (WrItemVO wrItemVO : vo.getChildrenVO()) { + wrItemVOMap.put(wrItemVO.getPk_wr_product(), wrItemVO); + } + } + List items = new ArrayList(); + String paramdata = NCCRestUtils.toJSONString(itemInfos).toJSONString(); + Log.getInstance("mm-mes").info("mes" + paramdata); + for (Map itemMap : itemInfos) { + WrItemVO item = wrItemVOMap.get(itemMap.get("pk_wr_product")); + if (MMValueCheck.isEmpty(item)) { + continue; + } + item.setStatus(VOStatus.UPDATED); + boolean hasGNumFlag = false; + for (String key : itemMap.keySet()) { + + if (QUALITYTABLE.equals(key)) { + List> qualityInfos = (List>) itemMap + .get(QUALITYTABLE); + List qualitys = this.getWrQualitys(qualityInfos); + item.setQualityvos(qualitys.toArray(new WrQualityVO[0])); + } else if (SERIALNOTABLE.equals(key)) { + List> snInfos = (List>) itemMap.get(SERIALNOTABLE); + List snVOs = this.getWrSerialNos(snInfos); + item.setSerialnovos(snVOs.toArray(new WrSerialNoVO[0])); + } else if (PICKNOTABLE.equals(key)) { + continue; + } else if (this.isGNumFilds(key)) { + hasGNumFlag = true; + } else { + if (MMValueCheck.isEmpty(itemMap.get(key))) { + continue; + } + if (BodyUnUpdateFiled.contains(key) && MMValueCheck.isNotEmpty(item.getAttributeValue(key)) + && !item.getAttributeValue(key).toString().equals(itemMap.get(key).toString())) { + return ResultMessageUtil.exceptionToJSON("ԣ" + key + "޸", "1"); + } + item.setAttributeValue(key, itemMap.get(key)); + } + } + if (hasGNumFlag) { + List qualitys = this.getWrQualitysByGnum(itemMap, item); + item.setQualityvos(qualitys.toArray(new WrQualityVO[0])); + } + items.add(item); + } + vo.setChildren(WrItemVO.class, items.toArray(new WrItemVO[0])); + voList.add(vo); + } + + AggWrVO[] aggvos = server.update(voList.toArray(new AggWrVO[0])); + boolean successFlag = true; + StringBuilder errMsg = new StringBuilder(); + if (MMArrayUtil.isNotEmpty(aggvos)) { + for (AggWrVO aggvo : aggvos) { + List validateList = aggvo.getParentVO().getExcpMsgList(); + if (MMCollectionUtil.isNotEmpty(validateList)) { + successFlag = false; + errMsg.append(aggvo.getParentVO().getVbillcode()); + errMsg.append(":"); + for (ValidationFailure validate : validateList) { + errMsg.append(validate.getMessage()); + errMsg.append(";"); + } + } + } + } + if (successFlag) { + return ResultMessageUtil.toJSON(aggvos, "޸ijɹ"); + } else { + ExceptionUtils.wrappBusinessException(errMsg.toString()); + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return null; + } + + @POST + @Path("delete") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString delete(Map paramMap) throws BusinessException { + if (MMValueCheck.isEmpty(paramMap)) { + return ResultMessageUtil.exceptionToJSON("쳣", "1"); + } + Set aggwrIds = new HashSet<>(); + Map idTsMap = new HashMap<>(); + if (!paramMap.containsKey("aggWrPk")) { + return ResultMessageUtil.exceptionToJSON("쳣Ҫ", "10000"); + } + aggwrIds.addAll((Collection) paramMap.get("aggWrPk")); + + try { + IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class); + AggWrVO[] aggWrVOSByIds = server.findAggWrVOSByIds(aggwrIds.toArray(new String[0])); + + List deleteVos = new ArrayList<>(); + for (AggWrVO aggWrVOSById : aggWrVOSByIds) { + if (!(WrBillStatusEnum.I_FREEDOM.intValue() == aggWrVOSById.getParentVO().getFbillstatus())) { + continue; + } + deleteVos.add(aggWrVOSById); + } + if (MMValueCheck.isEmpty(deleteVos)) { + return ResultMessageUtil.exceptionToJSON("״̬Ϊͨɾ", "1"); + } + server.delete(deleteVos.toArray(new AggWrVO[0])); + return ResultMessageUtil.toJSON(new String[0], "ɾɹ"); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + +} From 74ff3c897623c622a1e26424fcd1b995bd90f01d 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 15:29:59 +0800 Subject: [PATCH 4/9] =?UTF-8?q?mmpac=5F=E7=94=9F=E4=BA=A7=E6=8A=A5?= =?UTF-8?q?=E5=91=8Aopenapi=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=B1=BB=E5=9E=8B=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nccloud/openapi/mmpac/wr/WrResource.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java b/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java index a460f9d..e05334f 100644 --- a/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java +++ b/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java @@ -74,8 +74,8 @@ public class WrResource extends AbstractNCCRestResource { @POST @Path("saveAndApprove") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) + @Consumes({"application/json"}) + @Produces({"application/json"}) public JSONString saveAndApprove(List> paramList) { if (MMValueCheck.isEmpty(paramList)) { return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); @@ -261,8 +261,8 @@ public class WrResource extends AbstractNCCRestResource { @POST @Path("deleteByMesIDs") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) + @Consumes({"application/json"}) + @Produces({"application/json"}) public JSONString deleteByMesIDs(String[] mesIDs) { if (MMValueCheck.isEmpty(mesIDs)) { return ResultMessageUtil.exceptionToJSON("쳣", "1"); @@ -279,14 +279,15 @@ public class WrResource extends AbstractNCCRestResource { @POST @Path("newsave") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) + @Consumes({"application/json"}) + @Produces({"application/json"}) public JSONString newsave(Map paramsMap) { List> paramList = (List>) paramsMap.get("data"); if (MMValueCheck.isEmpty(paramList)) { return ResultMessageUtil.exceptionToJSON("쳣ҪͷϢͱϢ", "1"); } List voList = new ArrayList(); + BaseDAO baseDAO = new BaseDAO(); try { for (Map paramMap : paramList) { if (!paramMap.containsKey(HEADTABLE) || !paramMap.containsKey(BODYTABLE)) { @@ -347,12 +348,16 @@ public class WrResource extends AbstractNCCRestResource { vo.setChildren(WrItemVO.class, items.toArray(new WrItemVO[0])); voList.add(vo); IAPIWrMaintain server = NCLocator.getInstance().lookup(IAPIWrMaintain.class); -// List aggWrVOS = TransferCodeToPKTool.transferAggVO(voList); -// //뱨 -// List collection = (List) new BaseDAO().retrieveByClause(BilltypeVO.class, " pk_billtypecode='" + aggWrVOS.get(0).getParentVO().getVtrantypecode()+"'"); -// aggWrVOS.get(0).getParentVO().setVtrantypeid(collection.get(0).getPk_billtypeid()); -// aggWrVOS.get(0).getParentVO().setDbilldate(new UFDate()); -// AggWrVO[] aggvos = server.newsave(aggWrVOS.toArray(new AggWrVO[0])); + List aggWrVOS = TransferCodeToPKTool.transferAggVO(voList); + //뱨 + for (AggWrVO aggWrVO : aggWrVOS) { + List collection = (List) baseDAO.retrieveByClause(BilltypeVO.class, " pk_billtypecode='" + aggWrVO.getParentVO().getVtrantypecode() + "'"); + if(collection==null||collection.size()==0){ + throw new BusinessException("뱨ʧܣ鱨ͱ롾"+aggWrVO.getParentVO().getVtrantypecode()+""); + } + aggWrVO.getParentVO().setVtrantypeid(collection.get(0).getPk_billtypeid()); + aggWrVO.getParentVO().setDbilldate(new UFDate()); + } AggWrVO[] aggvos = server.newsave(voList.toArray(new AggWrVO[0])); boolean successFlag = true; StringBuilder errMsg = new StringBuilder(); @@ -384,8 +389,8 @@ public class WrResource extends AbstractNCCRestResource { @POST @Path("update") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) + @Consumes({"application/json"}) + @Produces({"application/json"}) public JSONString update(Map paramsMap) throws BusinessException { List> paramList = (List>) paramsMap.get("data"); if (MMValueCheck.isEmpty(paramList)) { @@ -532,8 +537,8 @@ public class WrResource extends AbstractNCCRestResource { @POST @Path("delete") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) + @Consumes({"application/json"}) + @Produces({"application/json"}) public JSONString delete(Map paramMap) throws BusinessException { if (MMValueCheck.isEmpty(paramMap)) { return ResultMessageUtil.exceptionToJSON("쳣", "1"); From 5d8f068dafde987e7bcb2d4493138da06647817a 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: Tue, 20 May 2025 14:33:47 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E9=94=90=E5=88=B6=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uapbd/doc/锐制基础数据视图.md | 190 +++++++++++++++++----------------- 1 file changed, 94 insertions(+), 96 deletions(-) diff --git a/uapbd/doc/锐制基础数据视图.md b/uapbd/doc/锐制基础数据视图.md index bb32f71..91c97f0 100644 --- a/uapbd/doc/锐制基础数据视图.md +++ b/uapbd/doc/锐制基础数据视图.md @@ -25,133 +25,131 @@ WHERE ## Ϸ ~~~sql -CREATE VIEW V_UAPBD_QUERYSYNC_MATERIALCLASS as - SELECT - m.code, - m.name, - m.pk_marbasclass , - p.name AS parent_name, - p.code AS parent_code, - oo.CODE AS org_code, - p.pk_marbasclass pk_parent, - GREATEST(p.TS, m.TS, oo.TS) AS TS +CREATE VIEW V_UAPBD_QUERYSYNC_MATERIALCLASS AS +SELECT + m.code, + m.name, + m.pk_marbasclass , + p.name AS parent_name, + p.code AS parent_code, + oo.CODE AS org_code, + p.pk_marbasclass pk_parent, + GREATEST(p.TS, m.TS) AS TS FROM - bd_marbasclass m - LEFT JOIN bd_marbasclass p ON m.pk_parent = p.pk_marbasclass - LEFT JOIN ORG_ORGS oo ON m.PK_ORG = oo.PK_ORG + bd_marbasclass m + LEFT JOIN bd_marbasclass p ON m.pk_parent = p.pk_marbasclass + LEFT JOIN ORG_ORGS oo ON m.PK_ORG = oo.PK_ORG WHERE - m.dr = 0 + m.dr = 0 ~~~ ## Ա ~~~sql -CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_PSNDOC" ("PK_PSNDOC", "CODE", "NAME", "DEPT_CODE", "DEPT_NAME", "ENABLESTATE", "ORG_CODE", "TS") AS - SELECT - p.pk_psndoc, - p.CODE, - p.NAME, - dept.code AS dept_code, - dept.name AS dept_name, - p.ENABLESTATE, - org.code as org_code, - GREATEST(p.TS, j.TS,org.TS,dept.TS) AS TS +CREATE VIEW V_UAPBD_QUERYSYNC_PSNDOC AS +SELECT + p.pk_psndoc, + p.CODE, + p.NAME, + dept.code AS dept_code, + dept.name AS dept_name, + p.ENABLESTATE, + org.code as org_code, + p.TS AS TS FROM - bd_psndoc p - LEFT JOIN bd_psnjob j ON p.pk_psndoc = j.pk_psndoc - AND j.ismainjob = 'Y' - AND j.dr = 0 - LEFT JOIN org_orgs org ON p.pk_org = org.pk_org - LEFT JOIN org_dept dept ON j.pk_dept = dept.pk_dept - -- LEFT JOIN org_group grp ON p.pk_group = grp.pk_group - -- LEFT JOIN bd_psncl cl ON j.pk_psncl = cl.pk_psncl - -- LEFT JOIN om_job job ON j.pk_job = job.pk_job - -- LEFT JOIN OM_POST post ON j.pk_post = post.pk_post + bd_psndoc p + LEFT JOIN bd_psnjob j ON p.pk_psndoc = j.pk_psndoc + AND j.ismainjob = 'Y' + AND j.dr = 0 + LEFT JOIN org_orgs org ON p.pk_org = org.pk_org + LEFT JOIN org_dept dept ON j.pk_dept = dept.pk_dept WHERE - p.dr = 0; + p.dr = 0; ~~~ ## ͻ ~~~sql -CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_CUSTOMER" ("PK_CUSTOMER", "NAME", "CODE", "ENABLESTATE", "SHORTNAME", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS - SELECT - c.pk_customer, - c.name, - c.code, - c.enablestate, - c.shortname, - oo.code AS org_code, - oo.name AS org_name, - og.code AS group_code, - og.name AS group_name, - GREATEST(c.ts, oo.TS, og.TS) AS TS +CREATE VIEW V_UAPBD_QUERYSYNC_CUSTOMER AS +SELECT + c.pk_customer, + c.name, + c.code, + c.enablestate, + c.shortname, + oo.code AS org_code, + oo.name AS org_name, + og.code AS group_code, + og.name AS group_name, + GREATEST(c.ts, oo.TS, og.TS) AS TS FROM - bd_customer c - LEFT JOIN org_orgs oo ON c.pk_org = oo.pk_org - LEFT JOIN org_group og ON c.pk_group = og.pk_group + bd_customer c + LEFT JOIN org_orgs oo ON c.pk_org = oo.pk_org + LEFT JOIN org_group og ON c.pk_group = og.pk_group WHERE - c.dr = 0; + c.dr = 0; ~~~ ## Ӧ ~~~sql -CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_SUPPLIER" ("CODE", "PK_SUPPLIER", "NAME", "ENABLESTATE", "SHORTNAME", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS - SELECT - s."CODE", - s."PK_SUPPLIER", - s."NAME", - s."ENABLESTATE", - s.shortname, - oo.code AS org_code, - oo.name AS org_name, - og.code AS group_code, - og.name AS group_name, - GREATEST(s.ts, oo.TS, og.TS) AS TS +CREATE VIEW V_UAPBD_QUERYSYNC_SUPPLIER AS +SELECT + s.CODE, + s.PK_SUPPLIER, + s.NAME, + s.ENABLESTATE, + s.shortname, + oo.code AS org_code, + oo.name AS org_name, + og.code AS group_code, + og.name AS group_name, + s.ts AS TS FROM - bd_supplier s - LEFT JOIN org_orgs oo ON s.pk_org = oo.pk_org - LEFT JOIN org_group og ON s.pk_group = og.pk_group + bd_supplier s + LEFT JOIN org_orgs oo ON s.pk_org = oo.pk_org + LEFT JOIN org_group og ON s.pk_group = og.pk_group WHERE - s.dr = 0; + s.dr = 0; ~~~ ## ~~~sql -CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_DEPT" ("CODE", "ENABLESTATE", "NAME", "PK_DEPT", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS - SELECT - d.CODE, - d.ENABLESTATE, - d.NAME, - d.PK_DEPT, - oo.code AS org_code, - oo.name AS org_name, - og.code AS group_code, - og.name AS group_name, - GREATEST(d.ts, oo.TS, og.TS) AS TS + CREATE VIEW V_UAPBD_QUERYSYNC_DEPT AS +SELECT + d.CODE, + d.NAME, + d.ENABLESTATE, + + d.PK_DEPT, + oo.code AS org_code, + oo.name AS org_name, + og.code AS group_code, + og.name AS group_name, + d.ts AS TS FROM - org_dept d - LEFT JOIN org_orgs oo ON d.pk_org = oo.pk_org - LEFT JOIN org_group og ON d.pk_group = og.pk_group + org_dept d + LEFT JOIN org_orgs oo ON d.pk_org = oo.pk_org + LEFT JOIN org_group og ON d.pk_group = og.pk_group WHERE - d.dr = 0; + d.dr = 0; ~~~ ## ֿ ~~~sql -CREATE OR REPLACE FORCE EDITIONABLE VIEW "TKNCC"."V_UAPBD_QUERYSYNC_STORDOC" ("CODE", "ENABLESTATE", "PK_STORDOC", "ORG_CODE", "ORG_NAME", "GROUP_CODE", "GROUP_NAME", "TS") AS - SELECT - sd.CODE", - sd.ENABLESTATE, - sd.PK_STORDOC, - so.code AS org_code, - so.name AS org_name, - og.code AS group_code, - og.name AS group_name, - GREATEST(sd.ts, so.TS, og.TS) AS TS + CREATE VIEW V_UAPBD_QUERYSYNC_STORDOC AS +SELECT + sd.CODE, + sd.name, + sd.ENABLESTATE, + sd.PK_STORDOC, + so.code AS org_code, + so.name AS org_name, + og.code AS group_code, + og.name AS group_name, + sd.ts AS TS FROM - bd_stordoc sd - LEFT JOIN org_stockorg so ON sd.pk_org = so.pk_stockorg - LEFT JOIN org_group og ON sd.pk_group = og.pk_group + bd_stordoc sd + LEFT JOIN org_stockorg so ON sd.pk_org = so.pk_stockorg + LEFT JOIN org_group og ON sd.pk_group = og.pk_group WHERE - sd.dr = 0; + sd.dr = 0; ~~~ \ No newline at end of file From d464b1adca1a515799d061b5d350f8bca2e101bb 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: Wed, 21 May 2025 10:08:05 +0800 Subject: [PATCH 6/9] =?UTF-8?q?mmpac=5F=E7=94=9F=E4=BA=A7=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=AE=A1=E6=89=B9=E6=8E=A8=E9=80=81=E9=94=90=E5=88=B6?= =?UTF-8?q?=5FV1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bs/mmpac/pmo/pac0002/bp/PMOApproveBP.java | 2 +- .../rule/AfterApprovingSynchronizeRuleRZ.java | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) 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 943304d..108cdeb 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ϵͳ + // ͵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 90ae7a7..6befb6f 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 @@ -47,7 +47,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { // ͵RZϵͳ pushToRZMOM(filteredOrders.toArray(new PMOAggVO[0])); } catch (Exception e) { - log.error("ͬRZϵͳʧ: " + e.getMessage(), e); + log.error("ͬRZϵͳʧ: " + e.getMessage()); ExceptionUtils.wrappException(e); } } @@ -59,8 +59,9 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { List aggvoList = new ArrayList<>(); for (PMOAggVO aggvo : pmoAggVOS) { String pkOrg = aggvo.getParentVO().getPk_org(); + Integer fbillstatus = aggvo.getParentVO().getFbillstatus(); String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); - if ("30401".equals(orgCode)) { + if ("30401".equals(orgCode)&&1==fbillstatus) { aggvoList.add(aggvo); } } @@ -110,17 +111,22 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { for (PMOItemVO body : bodys) { JSONObject detailItem = new JSONObject(); +// jhmx_wbid varchar(100) ϵͳid λϵͳ̨ΨһID + detailItem.put("jhmx_wbid", head.getCpmohid()); // ϵͳƻid detailItem.put("jhlb_wbid", head.getVtrantypecode()); // ϵͳƷID ID detailItem.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getCmaterialvid())); // Ԥƿ - detailItem.put("sxrq", body.getTplanstarttime().toString()); + if(body.getTplanstarttime()!=null){ + detailItem.put("sxrq", body.getTplanstarttime().toString()); + } // Ԥ깤 - detailItem.put("wcrq", body.getTplanendtime().toString()); - detailItem.put("gdbj", body.getFitemstatus()); + if(body.getTplanendtime()!=null){ + detailItem.put("wcrq", body.getTplanendtime().toString()); + } // ƻ - detailItem.put("jhsl", body.getNmmastnum().doubleValue()); + detailItem.put("jhsl", body.getNmmastnum().getDouble()); // ֿ 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())); @@ -130,11 +136,11 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { detailItem.put("ddbh", body.getVsalebillcode()); // detailItem.put("khddh", null); - detailItem.put("ddxh", null); + detailItem.put("ddxh", 1); // ע˵ detailItem.put("bzsm", body.getVnote()); // Ŀ - detailItem.put("htbz,wlzdycs06", body.getVdef1()); + detailItem.put("wlzdycs06", body.getVdef1()); details.add(detailItem); } } From 71aaa1d2dcee0507549ee3a74b8a3df650e2ddfc 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: Wed, 21 May 2025 10:30:46 +0800 Subject: [PATCH 7/9] =?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?=5F=E5=90=ABhttp=E5=B7=A5=E5=85=B7=E7=B1=BB=5FV1?= 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 +- .../nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java | 1 + .../public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) 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 5756daa..c00dff3 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java @@ -54,7 +54,7 @@ public class SignBP implements ISignBP, ISignRuleProvider processor.addAfterRule(new AfterSigningSynchronizeRuleMES()); // ̵㣨MES - // ۳ ǩֺ ͬ + // ۳ǩֺ ͬ processor.addAfterRule(new AfterSigningSynchronizeRuleRZ()); } 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 52aad8a..60937a5 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 @@ -50,6 +50,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule { } pushToRZMOM(newSaleOutVOS.toArray(new SaleOutVO[0])); }catch (Exception e){ + log.error("ͬ۳⵽ϵͳʧ: " + e.getMessage(), e); ExceptionUtils.wrappException(e); } } diff --git a/uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java b/uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java index 0828fe3..8ce69f7 100644 --- a/uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java +++ b/uapbd/src/public/nc/bs/uapbd/util/ThirdPartyPostRequestUtil.java @@ -17,8 +17,8 @@ import java.net.URL; */ public class ThirdPartyPostRequestUtil { - private static final int DEFAULT_CONNECT_TIMEOUT = 10000; - private static final int DEFAULT_READ_TIMEOUT = 10000; + private static final int DEFAULT_CONNECT_TIMEOUT = 20000; + private static final int DEFAULT_READ_TIMEOUT = 20000; /** * ϵͳ POST 󣬲 HTTP ״̬뷵 From ea487a89a7c14871fad522f7eedbc2b403b654ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= <125556714+Topfunplus@users.noreply.github.com> Date: Wed, 21 May 2025 12:46:10 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=94=80=E5=94=AE?= =?UTF-8?q?=E5=87=BA=E5=BA=93,=E5=BA=93=E5=AD=98=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=85=A5=E5=BA=93,=E9=94=80=E5=94=AE=E4=BA=A4=E8=B4=A7?= =?UTF-8?q?=E5=8D=95,=E7=9B=98=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ic/src/private/nc/bs/ic/m45/sign/SignBP.java | 61 ++++ .../rule/AfterSigningSynchronizeRuleMES.java | 270 +++++++++++++++++ ic/src/private/nc/bs/ic/m4c/sign/SignBP.java | 4 +- .../rule/AfterSigningSynchronizeRuleMES.java | 244 ++++++++-------- .../sign/rule/SalesDeliveryOrderRuleMES.java | 271 ++++++++++++++++++ .../AfterApprovingSynchronizeRuleMES.java | 55 +--- .../impl/utils/HttpPostOtherSysImpl.java | 2 +- .../commen/itf/utils/IHttpPostOtherSys.java | 1 - .../AfterApprovingSynchronizeRuleMES.java | 271 ++++++++++++++++++ .../action/main/ApproveSaleOrderAction.java | 223 ++++++++++++++ 10 files changed, 1242 insertions(+), 160 deletions(-) create mode 100644 ic/src/private/nc/bs/ic/m45/sign/SignBP.java create mode 100644 ic/src/private/nc/bs/ic/m45/sign/rule/AfterSigningSynchronizeRuleMES.java create mode 100644 ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java create mode 100644 so/src/private/nc/bs/so/m30/rule/approve/AfterApprovingSynchronizeRuleMES.java create mode 100644 so/src/private/nc/impl/so/m30/action/main/ApproveSaleOrderAction.java diff --git a/ic/src/private/nc/bs/ic/m45/sign/SignBP.java b/ic/src/private/nc/bs/ic/m45/sign/SignBP.java new file mode 100644 index 0000000..a52e3dd --- /dev/null +++ b/ic/src/private/nc/bs/ic/m45/sign/SignBP.java @@ -0,0 +1,61 @@ +package nc.bs.ic.m45.sign; + +import com.yonyou.cloud.ncc.plugin.entity.OperationInfo; +import nc.bs.ic.general.sign.ISignBP; +import nc.bs.ic.general.sign.ISignRuleProvider; +import nc.bs.ic.general.sign.SignBPTemplate; +import nc.bs.ic.m45.sign.rule.AfterSigningSynchronizeRuleMES; +import nc.bs.ic.m45.base.BPPlugInPoint; +import nc.bs.ic.m45.insert.rule.InsertOrSignRewritePayPlanInvoiceRule; +import nc.bs.ic.m45.sign.rule.*; +import nc.bs.ic.pub.util.DebugUtils; +import nc.bs.ic.pub.util.SagasUtils; +import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +import nc.itf.ic.m45.compensate.IPurchaseInSagasCompensate; +import nc.vo.ic.m45.entity.PurchaseInVO; +import nc.vo.ic.pub.util.VOEntityUtil; +import nc.vo.scmpub.res.billtype.ICBillType; +import nccloud.bs.ic.mobile.inbound.operation.rewrite.MobAfterPurchaseInSign; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class SignBP implements ISignBP, ISignRuleProvider { + public SignBP() { + } + + public PurchaseInVO[] sign(PurchaseInVO[] bills) { + DebugUtils.debug("purchasein-sign-begin"); + SignBPTemplate signBP = new SignBPTemplate(BPPlugInPoint.SignAction, this); + SagasUtils.frozenAndAddSaga(bills, ICBillType.PurchaseIn.getCode(), "1", (OperationInfo) null); + Map paramMap = new HashMap(); + paramMap.put("actionname", "sign_45"); + paramMap.put("hid", VOEntityUtil.getPksFromAggVO(bills)); + paramMap.put("vos", bills); + SagasUtils.compensate(paramMap, IPurchaseInSagasCompensate.class); + PurchaseInVO[] resultVOs = (PurchaseInVO[]) signBP.sign(bills); + DebugUtils.debug("purchasein-sign-end"); + return resultVOs; + } + + public void addAfterRule(PurchaseInVO[] vos, AroundProcesser processor) { + processor.addAfterRule(new SignRewritePayPlanConfirmDataRule()); + processor.addAfterRule(new InsertOrSignRewritePayPlanInvoiceRule("1001Z01000000000F04P")); + processor.addAfterRule(new AfterRuleForRewritePUSettle()); + processor.addAfterRule(new AfterRuleForPush5X()); + processor.addAfterRule(new AfterSignRuleForFinanceProcess()); + processor.addAfterRule(new AfterSignRuleForLiabilityProcess()); + processor.addAfterRule(new MobAfterPurchaseInSign()); + processor.addAfterRule(new SignM45AndRewriteCTPayPlan()); + processor.addAfterRule(new SignInsertFeeDetailRule()); + // ǩֺMESϵͳ + processor.addAfterRule(new AfterSigningSynchronizeRuleMES()); + } + + public void addBeforeRule(PurchaseInVO[] vos, AroundProcesser processor) { + processor.addBeforeRule(new VOSagaFrozenValidateRule(true)); + processor.addBeforeRule(new BeforeRuleForCheckPU()); + } +} diff --git a/ic/src/private/nc/bs/ic/m45/sign/rule/AfterSigningSynchronizeRuleMES.java b/ic/src/private/nc/bs/ic/m45/sign/rule/AfterSigningSynchronizeRuleMES.java new file mode 100644 index 0000000..ed0227c --- /dev/null +++ b/ic/src/private/nc/bs/ic/m45/sign/rule/AfterSigningSynchronizeRuleMES.java @@ -0,0 +1,270 @@ +package nc.bs.ic.m45.sign.rule; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +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.material.MaterialVO; +import nc.vo.bd.material.measdoc.MeasdocVO; +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.ic.m45.entity.PurchaseInVO; +import nc.vo.ic.m45.entity.PurchaseInBodyVO; +import nc.vo.ic.m45.entity.PurchaseInHeadVO; +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.vorg.DeptVersionVO; +import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; + +/** + * ɹջǩֺMESϵͳ + */ +public class AfterSigningSynchronizeRuleMES implements IRule { + private static final String PURCHASE_IN_URL = "/GTHINKING/AjaxService/N_CGSJJSA/102223002.ashx/CGSH_INSERT"; // ɹջͬӿ + private static final String logginfo = "OALOG"; + private static final Log obmlog = Log.getInstance(logginfo); + private static final BaseDAO dao = new BaseDAO(); + + @Override + public void process(PurchaseInVO[] purchaseInVOS) { + try { + if (purchaseInVOS == null || purchaseInVOS.length == 0) { + return; + } + + // 鲢ɸѡɹջ + List filteredPurchaseInVOS = checkAndFilterBills(purchaseInVOS); + if (filteredPurchaseInVOS.isEmpty()) { + return; + } + + // ʼHTTP󹤾 + IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + + // ÿɹջ + for (PurchaseInVO purchaseInVO : filteredPurchaseInVOS) { + PurchaseInHeadVO head = purchaseInVO.getHead(); + PurchaseInBodyVO[] bodys = purchaseInVO.getBodys(); + // Ҫ͵ + JSONObject syncData = buildSyncData(head, bodys); + // ݵMESϵͳ + httpPostOtherSys.sendToExternalSystem(PURCHASE_IN_URL, syncData); + } + } catch (Exception e) { + obmlog.error("AfterSigningSynchronizeRuleMES-쳣:" + e.getMessage(), e); + ExceptionUtils.wrappException(e); + } + } + + /** + * 鲢ɸѡҪͬĵ + */ + private List checkAndFilterBills(PurchaseInVO[] purchaseInVOS) throws BusinessException { + List result = new ArrayList<>(); + + for (PurchaseInVO vo : purchaseInVOS) { + // ֯ǷΪ֯ + if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) { + result.add(vo); + } + } + + return result; + } + + /** + * ϸ + */ + private JSONArray buildDetailsData(PurchaseInBodyVO[] bodys) throws BusinessException { + JSONArray details = new JSONArray(); + if (bodys != null) { + for (PurchaseInBodyVO body : bodys) { + JSONObject detailItem = new JSONObject(); + // ջţ + detailItem.put("orderNo", null); + // ջţ- ʹȷıֶcrowno + detailItem.put("orderSn", body.getCrowno()); + // ͣ- ʹñֶcbodytranstypecode + detailItem.put("type", null); + // ࣨ- H:, F:, L: + detailItem.put("costOrder", null); + // ɹ - Դݺvsourcebillcode + detailItem.put("poNo", body.getVsourcebillcode()); + // ɹ - Դкvsourcerowno + detailItem.put("poSn", body.getVsourcerowno()); + // ϱ루 + String materialCode = transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, + MaterialVO.PK_MATERIAL, body.getCmaterialvid()); + detailItem.put("materialId", materialCode); + // λ- ʹõλcastunitidλcunitid + detailItem.put("unit", transferCodeByPk(MeasdocVO.getDefaultTableName(), MeasdocVO.CODE, MeasdocVO.PK_MEASDOC, body.getCastunitid())); + // + detailItem.put("batchNum", null); + // - PurchaseInBodyVOûֱӶӦֶΣԴvdefֶλȡ + detailItem.put("productNum", null); // vdef1洢 + // ϵ + String scaleFactor = body.getVchangerate(); + detailItem.put("scaleFactor", transferSpecialField(scaleFactor)); + // TODO ĵûжӦϵ + UFDouble taxRate = body.getNtaxrate(); + detailItem.put("taxRate", taxRate != null ? taxRate.getDouble() : null); + // Ӧ- ʹnshouldassistnum + UFDouble recQty = body.getNshouldassistnum(); + detailItem.put("recQty", recQty != null ? recQty.getDouble() : null); + // Ӧ- ʹnshouldnum + UFDouble mainRecQty = body.getNshouldnum(); + detailItem.put("mainRecQty", mainRecQty != null ? mainRecQty.getDouble() : null); + // Ӧ - Զֶ + detailItem.put("assitRecQty", null); + // ԭҺ˰۸ - + UFDouble priceIncludeTax = body.getNpickupnum(); + detailItem.put("priceIncludeTax", priceIncludeTax != null ? priceIncludeTax.getDouble() : null); + // ԭҺ˰ - ʹnorigtaxmny + UFDouble amountIncludeTax = body.getNorigtaxmny(); + detailItem.put("amountIncludeTax", amountIncludeTax != null ? amountIncludeTax.getDouble() : null); + // ԭ˰۸ - + UFDouble priceNoTax = body.getNorigprice(); + detailItem.put("priceNoTax", priceNoTax != null ? priceNoTax.getDouble() : null); + // ԭ˰ - ʹnorigmny + UFDouble amountNoTax = body.getNqtnetprice(); + detailItem.put("amountNoTax", amountNoTax != null ? amountNoTax.getDouble() : null); + // ˰ - ʹntax + UFDouble taxAmount = body.getNtax(); + detailItem.put("taxAmount", taxAmount != null ? taxAmount.getDouble() : null); + // ע - ʹvnotebody + detailItem.put("remark", body.getVnotebody()); + // ԭջϢ + detailItem.put("oldOrderNo", null); + detailItem.put("oldOrderSn", null); + details.add(detailItem); + } + } + return details; + } + + /** + * MESϵͳӿڹ淶 + */ + private JSONObject buildSyncData(PurchaseInHeadVO head, PurchaseInBodyVO[] bodys) throws BusinessException { + // + JSONObject requestData = new JSONObject(); + JSONObject data = new JSONObject(); + + // ջϢ + // ջţ + data.put("orderNo", head.getVbillcode()); + // ջ + UFDate dbilldate = head.getDbilldate(); + data.put("orderDate", dbilldate != null ? dbilldate.toString().substring(0, 10) : null); + // ջ + data.put("orderType", "P"); + // + data.put("type", null); + // ֿ + String storeId = transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, + StordocVO.PK_STORDOC, head.getCwarehouseid()); + data.put("storeId", storeId); + + // ɹID- ע⣺ֵֶ䣬ɹֶΪcdptidcdeptid + String departmentId = transferCodeByPk(DeptVersionVO.getDefaultTableName(), DeptVersionVO.CODE, + DeptVersionVO.PK_VID, head.getCdptvid()); + data.put("departmentId", departmentId); + // ɹԱ - ɹԱֶΪcbizid + String purchaser = transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, + PsndocVO.PK_PSNDOC, head.getCbizid()); + data.put("purchaser", purchaser); + // Ӧ̱루 + String supplyId = transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, + SupplierVO.PK_SUPPLIER, head.getCvendorid()); + data.put("supplyId", supplyId); + // ID + data.put("currency", null); + // ʣ + data.put("rate", null); + // 㷽ʽ + data.put("settleType", null); + // Ʊ + data.put("billBasis", null); + // ɷʽ- P:ɹ, Z:ֱ + data.put("genType", "P"); + // ࣨ- N:, Y: + data.put("costOrder", "N"); + // Ƿ˻- N:, Y: + data.put("returned", head.getFreplenishflag()); + // ע + data.put("remark", head.getVnote()); + // άϢ + data.put("creatorNo", null); // + data.put("creator", head.getBillmaker()); // Ƶ + data.put("creatTime", head.getDmakedate() != null ? head.getCreationtime().toString() : null); // ʱ + + // ϸ + JSONArray details = buildDetailsData(bodys); + data.put("Details", details); + requestData.put("Data", data); + + obmlog.debug("AfterSigningSynchronizeRuleMES-ɹջ: " + requestData.toJSONString()); + + return requestData; + } + + /** + * תֶ 1/1 תΪС 1.0 + */ + + private String transferSpecialField(String field) { + if (field == null || field.trim().isEmpty()) { + return null; + } + String[] split = field.split("/"); + if (split.length == 2) { + String numStr = split[0].trim(); + String denStr = split[1].trim(); + + if (denStr.equals("0")) { + return "0.00"; // ĸΪ + } + + try { + BigDecimal numerator = new BigDecimal(numStr); + BigDecimal denominator = new BigDecimal(denStr); + return numerator.divide(denominator, 2, RoundingMode.HALF_UP).toString(); + } catch (NumberFormatException e) { + return field; // Ƿ֣ԭֶ + } + } + return field; + } + + /** + * ѯ + */ + 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/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java b/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java index 5756daa..bb0636e 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/SignBP.java @@ -50,10 +50,10 @@ public class SignBP implements ISignBP, ISignRuleProvider processor.addAfterRule(new ArsubToVoucherRule()); processor.addAfterRule(new SaleOutProceedsRuleCG()); processor.addAfterRule(new MobAfterSignMessageRule()); + // ۳ һ ύ۽ ͬ۳ⵥorderNoһ + processor.addAfterRule(new SalesDeliveryOrderRuleMES()); // ۳ ǩֺ ͬMES˼άϵͳ processor.addAfterRule(new AfterSigningSynchronizeRuleMES()); - // ̵㣨MES - // ۳ ǩֺ ͬ processor.addAfterRule(new AfterSigningSynchronizeRuleRZ()); } diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleMES.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleMES.java index 93bad7a..b38d1d0 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleMES.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleMES.java @@ -8,6 +8,7 @@ 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.currtype.CurrtypeVO; import nc.vo.bd.cust.CustomerVO; import nc.vo.bd.material.MaterialVO; import nc.vo.bd.material.measdoc.MeasdocVO; @@ -20,9 +21,13 @@ 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.exception.ExceptionUtils; import nc.vo.pubapp.pattern.pub.SqlBuilder; import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; +import net.sf.mpxj.primavera.schema.CurrencyType; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.SimpleDateFormat; @@ -31,10 +36,9 @@ import java.text.SimpleDateFormat; */ 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(); + private static final BaseDAO dao = new BaseDAO(); public AfterSigningSynchronizeRuleMES() { } @@ -55,14 +59,12 @@ public class AfterSigningSynchronizeRuleMES implements IRule { JSONObject syncData = buildSyncData(hvo, bvos); if (syncData != null) { // ݵ˼άϵͳʹHttpPostOtherSysImpl - String mesResponse = httpPostOtherSys.callMes(SALE_OUT_URL, syncData); - obmlog.debug("AfterSigningSynchronizeRule-˼άϵͳӦ: " + mesResponse); - // Ӧ - processResponse(hvo.getVbillcode(), mesResponse); + httpPostOtherSys.sendToExternalSystem(SALE_OUT_URL, syncData); } } } catch (Exception e) { obmlog.error("AfterSigningSynchronizeRule-쳣:" + e.getMessage(), e); + ExceptionUtils.wrappException(e); } } @@ -77,128 +79,118 @@ public class AfterSigningSynchronizeRuleMES implements IRule { return null; } JSONObject requestData = new JSONObject(); - requestData.put("operation_type", "I"); - JSONObject info = new JSONObject(); - // - ֵֶӳ - info.put("orderNo", hvo.getVbillcode()); // ID - ݺ(vbillcode) + JSONObject dataObj = new JSONObject(); + // - Ҫ + dataObj.put("orderNo", hvo.getVbillcode()); // ջ - ݺ(vbillcode) // ڸʽת UFDate dbilldate = hvo.getDbilldate(); - info.put("orderDate", dbilldate.toString()); // ᵥ - (dbilldate) - info.put("planDate", dbilldate.toString()); // ƻ - ʹͬĵ - info.put("actureDate", dbilldate.toString()); - info.put("genType", null); - info.put("type", "XSCK"); + dataObj.put("orderDate", dbilldate.toString().substring(0, 10)); // ջ - (dbilldate)ʽyyyy-MM-dd + dataObj.put("planDate", dbilldate.toString().substring(0, 10)); // ƻ - (dbilldate)ʽyyyy-MM-dd + dataObj.put("actureDate", dbilldate.toString().substring(0, 10)); // ʵ - (dbilldate)ʽyyyy-MM-dd + dataObj.put("orderType", null); // ջ - ޶Ӧֶ + dataObj.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"); // ƱĬֵ - info.put("effDate", null); - info.put("consignStoreId", null); // ۲ֿID - info.put("consignType", null); // - info.put("operatorNo", null); // ˹ - Ƶ(billmaker) - 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ϸ + dataObj.put("departmentId", transferCodeByPk(DeptVO.getDefaultTableName(), + DeptVO.CODE, DeptVO.PK_DEPT, hvo.getCdptvid())); // ɹID + // ֿ - ֿ(cwarehouseid) + dataObj.put("storeId", transferCodeByPk(RackVO.getDefaultTableName(), + RackVO.CODE, RackVO.PK_RACK, hvo.getCwarehouseid())); // ֿ + + + // ɹԱ - ҵԱ(cbizpersonid) + dataObj.put("purchaser", transferCodeByPk(PsndocVO.getDefaultTableName(), + PsndocVO.CODE, PsndocVO.PK_PSNDOC, hvo.getCbizid())); + + // ͻID - ͻ(ccustomerid)ΪDzɹùӦӳ + dataObj.put("supplyId", transferCodeByPk(CustomerVO.getDefaultTableName(), + CustomerVO.CODE, CustomerVO.PK_CUSTOMER, hvo.getCcustomerid())); + // + dataObj.put("sType", "N"); + //߷Ʊ + dataObj.put("billing", "Y"); + //Ʊ + dataObj.put("billingBasis", "S"); + //Ч + dataObj.put("effDate", null); + //۲ֿID + dataObj.put("consignStoreId", null); + // + dataObj.put("consignType", null); + //˹ + dataObj.put("operatorNo", null); + // + dataObj.put("operatorName", null); + //Ա + dataObj.put("storeKeeper", null); + //ͻID + dataObj.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, hvo.getCcustomerid())); + //ɱ־ + dataObj.put("mark", "Y"); + //ע + dataObj.put("remark", hvo.getVnote()); + + + // Detailsϸ JSONArray details = new JSONArray(); if (bvos != null) { for (SaleOutBodyVO bvo : bvos) { - 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); // - // 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) - // ͻϢ - // ͻID - ͻ(casscustid) - detail.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); - // ӦϢ - // ӦID - Ӧ(cvendorid) - detail.put("supplierId", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); - detail.put("color", null); - // - detail.put("manufactureDate", null); // (dproducedate) - detail.put("properties", null); - detail.put("remark", bvo.getVnotebody()); // ע - бע(vnotebody) + // + dataObj.put("exRate", bvo.getNchangestdrate()); + JSONObject detail = new JSONObject(); + detail.put("orderNo", hvo.getVbillcode()); // ID - ݺ(vbillcode) - + detail.put("sequenceNum", bvo.getCrowno()); // - к(crowno) - + detail.put("type", "XSCK"); // - ĬXSCK + + // ԴϢ + detail.put("saleOrderNo", bvo.getVsourcebillcode()); // SOID - Դݺ(vsourcebillcode) + detail.put("saleSequenceNum", bvo.getVsourcerowno()); // SO - Դк(vsourcerowno) + detail.put("allocationNum", null); // + + // Ϣ - + detail.put("materialId", transferCodeByPk(MaterialVO.getDefaultTableName(), + MaterialVO.CODE, MaterialVO.PK_MATERIAL, bvo.getCmaterialoid())); // ID - + + detail.put("unit", transferCodeByPk(MeasdocVO.getDefaultTableName(), + MeasdocVO.CODE, MeasdocVO.PK_MEASDOC, bvo.getCunitid())); // λ - + + detail.put("productNum", null); // + + // λ - + detail.put("storageId", transferCodeByPk(RackVO.getDefaultTableName(), + RackVO.CODE, RackVO.PK_RACK, bvo.getClocationid())); // λ - + + detail.put("batchNum", bvo.getVbatchcode()); // - + detail.put("scaleFactor", transferSpecialField(bvo.getVchangerate())); // ϵ - + + // Ϣ - + detail.put("issuedQty", bvo.getNshouldassistnum()); // Ӧ - + detail.put("mIssuedQty", bvo.getNshouldnum()); // Ӧ - + detail.put("actQry", bvo.getNassistnum()); // ʵ - + detail.put("mActQry", bvo.getNnum()); // ʵ - + detail.put("assistActQry", bvo.getNassistnum()); // ʵ - + + // ͻ͹ӦϢ + 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())); // ӦID + + detail.put("manufactureDate", bvo.getDproducedate()); // + detail.put("color", null); // ɫ + detail.put("properties", null); + detail.put("remark", bvo.getVnotebody()); // ע - бע(vnotebody) details.add(detail); } } - info.put("details", details); - - // infoӵ - requestData.put("info", info); - + requestData.put("operation_type", "I"); + requestData.put("info", dataObj); + dataObj.put("details", details); return requestData; } - /** - * ȫȡֵַָֹ쳣 - */ - private String getStringValue(Object value) { - return value == null ? "" : value.toString(); - } - - /** - * ˼άϵͳӦ - */ - private void processResponse(String vbillcode, String response) { - if (StringUtils.isEmpty(response)) { - obmlog.error("AfterSigningSynchronizeRule-ӦΪգݺ: " + vbillcode); - return; - } - - try { - JSONObject respObj = JSONObject.parseObject(response); - JSONObject result = respObj.getJSONObject("result"); - if (result != null) { - boolean success = result.getBooleanValue("success"); - String message = result.getString("message"); - String errorMessage = result.getString("errorMessage"); - String orderNo = result.getString("orderNo"); - - if (success) { - obmlog.info("AfterSigningSynchronizeRule-ͬɹݺ: " + vbillcode + ", ص: " + orderNo + ", Ϣ: " + message); - } else { - obmlog.error("AfterSigningSynchronizeRule-ͬʧܣݺ: " + vbillcode + ", : " + errorMessage); - throw new BusinessException("ͬ˼άϵͳʧ: " + errorMessage); - } - } - } catch (Exception e) { - 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; @@ -214,4 +206,28 @@ public class AfterSigningSynchronizeRuleMES implements IRule { } return o.toString(); } + + private String transferSpecialField(String field) { + if (field == null || field.trim().isEmpty()) { + return null; + } + String[] split = field.split("/"); + if (split.length == 2) { + String numStr = split[0].trim(); + String denStr = split[1].trim(); + + if (denStr.equals("0")) { + return "0.00"; // ĸΪ + } + + try { + BigDecimal numerator = new BigDecimal(numStr); + BigDecimal denominator = new BigDecimal(denStr); + return numerator.divide(denominator, 2, RoundingMode.HALF_UP).toString(); + } catch (NumberFormatException e) { + return field; // Ƿ֣ԭֶ + } + } + return field; + } } diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java new file mode 100644 index 0000000..59bada9 --- /dev/null +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java @@ -0,0 +1,271 @@ +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.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.currtype.CurrtypeVO; +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.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.vorg.DeptVersionVO; +import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; + +import java.math.BigDecimal; +import java.math.RoundingMode; + + +/** + * ۽(BIP) MES + */ +public class SalesDeliveryOrderRuleMES implements IRule { + private static final BaseDAO dao = new BaseDAO(); + // MESϵͳAPIӿڵַ + private static final String MES_API_URL = "/GTHINKING/AjaxService/N_MISPRO/SalesDeliveryOrder.ashx/SaveData"; + // ɾ۽ӿڵַ + private static final String MES_DELETE_API_URL = "/GTHINKING/AjaxService/N_XSSJJSA/102397002.ashx/SOTH_DELETE"; + private static final Log obmlog = Log.getInstance("OALOG"); + + @Override + public void process(SaleOutVO[] saleOutVOS) { + try { + if (saleOutVOS == null || saleOutVOS.length == 0) { + return; + } + + // ʼHTTP󹤾 + IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + + // ÿ۽ + for (SaleOutVO saleOutVO : saleOutVOS) { + SaleOutHeadVO hvo = (SaleOutHeadVO) saleOutVO.getParentVO(); + SaleOutBodyVO[] bvos = (SaleOutBodyVO[]) saleOutVO.getChildrenVO(); + + // Ҫ͵ + JSONObject syncData = buildSyncData(hvo, bvos); + if (syncData != null) { + // ÿ۽֮ǰ ɾ Ȼ + String orderNo = hvo.getVbillcode(); + boolean flag = deleteSalesDeliveryOrder(orderNo); + if (flag) { + // ݵMESϵͳ + obmlog.debug("SalesDeliveryOrderRuleMES-׼۽: " + hvo.getVbillcode()); + httpPostOtherSys.sendToExternalSystem(MES_API_URL, syncData); + } + } + } + } catch (Exception e) { + obmlog.error("SalesDeliveryOrderRuleMES-쳣:" + e.getMessage(), e); + ExceptionUtils.wrappException(e); + } + } + + /** + * MESϵͳӿڹ淶 + */ + private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) throws BusinessException { + obmlog.debug("SalesDeliveryOrderRuleMES-ʼ۽: " + hvo.getVbillcode()); + + // ֯Ƿ + if (!hvo.getPk_org().equals("0001A110000000000677")) { + obmlog.debug("SalesDeliveryOrderRuleMES-۽,Ϊ˵֯ǵ: " + hvo.getVbillcode()); + return null; + } + + JSONObject requestData = new JSONObject(); + JSONObject info = new JSONObject(); + // - ֶδ + // ֶ + info.put("orderNo", hvo.getVbillcode()); //  + info.put("orderDate", hvo.getDbilldate() == null ? null : hvo.getDbilldate().toString().substring(0, 10)); // TODO ڣʽyyyy-MM-dd + info.put("deliveryDate", hvo.getDbilldate() == null ? null : hvo.getDbilldate().toString().substring(0, 10)); //  TODO ƻڣõ + // ͻID - ͻ(ccustomerid) + info.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), + CustomerVO.CODE, CustomerVO.PK_CUSTOMER, hvo.getCcustomerid())); // ͻ + // Ʊλ + info.put("invoicingUnit", null); // TODO Ʊλ룬޶Ӧֶ + // ۲ű + info.put("departmentId", transferCodeByPk(DeptVersionVO.getDefaultTableName(), + DeptVersionVO.CODE, DeptVersionVO.PK_VID, hvo.getCdptvid())); // ۲ű + + + // Ա + info.put("seller", transferCodeByPk(PsndocVO.getDefaultTableName(), + PsndocVO.CODE, PsndocVO.PK_PSNDOC, hvo.getCbiztype())); // TODO Ա + + info.put("exchangeRate", null); // TODO ʣ޶Ӧֶ ۳Ҳû + info.put("invoicingBasis", "S"); // Ʊ + info.put("settlementType", null); // TODO 㷽ʽ޶Ӧֶ + + // ֿ + info.put("warehouseId", transferCodeByPk(RackVO.getDefaultTableName(), + RackVO.CODE, RackVO.PK_RACK, hvo.getCwarehouseid())); // ֿ + + info.put("type", "XSJH"); // ͣ۽ + info.put("genType", null); // TODO ɷʽ޶Ӧֶ + info.put("returned", null); // TODO Ƿ˻޶Ӧֶ + + // DZֶ + info.put("transportMode", null); // ䷽ʽ + info.put("deliveryAddress", null); // ջص + info.put("contacts", null); // ϵ + info.put("contactNum", null); // ϵ绰 + info.put("originalNo", null); // ԭ + info.put("remark", hvo.getVnote()); // ע + info.put("creatorNo", null); // ά˹ + info.put("creator", null); // ά + info.put("creatTime", null); // άʱ + + // ϸ + JSONArray details = new JSONArray(); + if (bvos != null) { + for (SaleOutBodyVO bvo : bvos) { + JSONObject detail = new JSONObject(); + // ͷֶҪֶ + // ұ + info.put("currency", transferCodeByPk(CurrtypeVO.getDefaultTableName(), + CurrtypeVO.CODE, CurrtypeVO.PK_CURRTYPE, bvo.getCorigcurrencyid())); + + // ֶ + detail.put("orderNo", hvo.getVbillcode()); //  + detail.put("orderSn", bvo.getCrowno()); // TODO + + // ɷʽΪʱ + detail.put("soOrderNo", bvo.getVsourcebillcode()); // TODO ۶ + detail.put("soSequenceNum", bvo.getVsourcerowno()); // TODO ۶ + + // ϱ + detail.put("materialId", transferCodeByPk(MaterialVO.getDefaultTableName(), + MaterialVO.CODE, MaterialVO.PK_MATERIAL, bvo.getCmaterialoid())); // ϱ + + // λ + detail.put("unit", transferCodeByPk(MeasdocVO.getDefaultTableName(), + MeasdocVO.CODE, MeasdocVO.PK_MEASDOC, bvo.getCunitid())); // λ + + detail.put("scaleFactor", transferSpecialField(bvo.getVchangerate())); // ϵ + detail.put("taxRate", bvo.getNtaxrate()); // ˰ + detail.put("recQty", bvo.getNshouldassistnum()); // Ӧ + detail.put("mainRecQty", bvo.getNshouldnum()); // TODO Ӧ + + // DZֶ + detail.put("batchNum", null); // + detail.put("productNum", null); // + detail.put("assitRecQty", null); // Ӧ + detail.put("priceIncludeTax", null); // ԭҺ˰۸ + detail.put("amountIncludeTax", null); // ԭҺ˰ + detail.put("taxAmount", null); // ˰ + detail.put("remark", null); // ע + + details.add(detail); + } + } + info.put("Details", details); + + // infoӵ + requestData.put("Data", info); + + return requestData; + } + + /** + * ȡӦı + */ + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if (pk == null || pk.trim().isEmpty()) { + 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(); + } + + /** + * ɾϵͳе۽ + * + * @param orderNo Ҫɾ۽ + * @return ɾǷɹ + * @throws BusinessException ҵ쳣 + */ + public boolean deleteSalesDeliveryOrder(String orderNo) throws BusinessException { + try { + if (orderNo == null || orderNo.trim().isEmpty()) { + throw new BusinessException("۽ŲΪ"); + } + + obmlog.debug("SalesDeliveryOrderRuleMES-׼ɾϵͳ۽: " + orderNo); + + // + JSONObject requestData = new JSONObject(); + JSONObject dataObj = new JSONObject(); + dataObj.put("orderNo", orderNo); + requestData.put("Data", dataObj); + + // ʼHTTP󹤾 + IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + + // ɾ + String response = httpPostOtherSys.callMes(MES_DELETE_API_URL, requestData); + obmlog.debug("SalesDeliveryOrderRuleMES-ɾ󷵻ؽ: " + response); + + // ؽ + JSONObject jsonResponse = JSONObject.parseObject(response); + boolean isSuccess = jsonResponse.getBooleanValue("Success"); + String errorMessage = jsonResponse.getString("ErrorMessage"); + + if (!isSuccess) { + obmlog.error("SalesDeliveryOrderRuleMES-ɾ۽ʧ: " + orderNo + ", Ϣ: " + errorMessage); + throw new BusinessException("ɾ۽ʧ: " + (errorMessage != null ? errorMessage : "δ֪")); + } + + obmlog.debug("SalesDeliveryOrderRuleMES-ɹɾ۽: " + orderNo); + return true; + } catch (Exception e) { + obmlog.error("SalesDeliveryOrderRuleMES-ɾ۽쳣:" + e.getMessage(), e); + throw new BusinessException("ɾ۽ʱ쳣: " + e.getMessage(), e); + } + } + + private String transferSpecialField(String field) { + if (field == null || field.trim().isEmpty()) { + return null; + } + String[] split = field.split("/"); + if (split.length == 2) { + String numStr = split[0].trim(); + String denStr = split[1].trim(); + + if (denStr.equals("0")) { + return "0.00"; // ĸΪ + } + + try { + BigDecimal numerator = new BigDecimal(numStr); + BigDecimal denominator = new BigDecimal(denStr); + return numerator.divide(denominator, 2, RoundingMode.HALF_UP).toString(); + } catch (NumberFormatException e) { + return field; // Ƿ֣ԭֶ + } + } + return field; + } +} 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 e420d26..8f40382 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 @@ -3,7 +3,6 @@ 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; @@ -21,17 +20,17 @@ import nc.vo.org.DeptVO; 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.vorg.DeptVersionVO; import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; -import java.text.SimpleDateFormat; - /** * ̵㣨MES */ public class AfterApprovingSynchronizeRuleMES implements IRule { - private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/U20231172_N_XSSJJSA/102397009.ashx/KCPD_INSERT"; // ̵㵥ͬӿ + private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/N_KCSJJS/101527005.ashx/KCPD_INSERT"; // ̵㵥ͬӿ private static final String logginfo = "OALOG"; private static final Log obmlog = Log.getInstance(logginfo); private static final BaseDAO dao = new BaseDAO(); @@ -58,15 +57,13 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { if (syncData != null) { // ݵ˼άϵͳʹHttpPostOtherSysImpl - String mesResponse = httpPostOtherSys.callMes(INV_COUNT_URL, syncData); - obmlog.debug("AfterApprovingSynchronizeRule-˼άϵͳӦ: " + mesResponse); + httpPostOtherSys.sendToExternalSystem(INV_COUNT_URL, syncData); - // Ӧ - processResponse(hvo.getVbillcode(), mesResponse); } } } catch (Exception e) { obmlog.error("AfterApprovingSynchronizeRule-쳣:" + e.getMessage(), e); + ExceptionUtils.wrappException(e); } } @@ -82,6 +79,7 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { } // ¹淶 + JSONObject requestBody = new JSONObject(); JSONObject requestData = new JSONObject(); // ̵Ϣ ̵㵥 ΪʱԶ @@ -92,7 +90,7 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { requestData.put("CKID", warehouseCode); // ̵㲿ű - String deptCode = transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, hvo.getCdptvid()); + String deptCode = transferCodeByPk(DeptVersionVO.getDefaultTableName(), DeptVersionVO.CODE, DeptVersionVO.PK_VID, hvo.getCdptvid()); requestData.put("BMID", deptCode); // ̵ requestData.put("PDR", getStringValue(hvo.getCountoperator())); @@ -115,11 +113,12 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { // ȡŲתΪ String crownStr = bvo.getCrowno(); try { - detail.put("XH", Double.parseDouble(crownStr)); // - + // + detail.put("XH", Double.parseDouble(crownStr)); } catch (NumberFormatException e) { - detail.put("XH", null); // Ĭ + 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())); @@ -160,8 +159,9 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { } } requestData.put("DETAILS", details); + requestBody.put("KCPD", requestData); - return requestData; + return requestBody; } /** @@ -171,35 +171,6 @@ public class AfterApprovingSynchronizeRuleMES implements IRule { return value == null ? "" : value.toString(); } - /** - * ˼άϵͳӦ - */ - private void processResponse(String vbillcode, String response) { - if (StringUtils.isEmpty(response)) { - obmlog.error("AfterApprovingSynchronizeRule-ӦΪգݺ: " + vbillcode); - return; - } - - try { - JSONObject respObj = JSONObject.parseObject(response); - JSONObject result = respObj.getJSONObject("result"); - if (result != null) { - boolean success = result.getBooleanValue("success"); - String message = result.getString("message"); - String errorMessage = result.getString("errorMessage"); - String orderNo = result.getString("orderNo"); - - if (success) { - obmlog.info("AfterApprovingSynchronizeRule-ͬɹݺ: " + vbillcode + ", ص: " + orderNo + ", Ϣ: " + message); - } else { - obmlog.error("AfterApprovingSynchronizeRule-ͬʧܣݺ: " + vbillcode + ", : " + errorMessage); - throw new BusinessException("ͬ˼άϵͳʧ: " + errorMessage); - } - } - } catch (Exception e) { - 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)) { 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 bfdc252..23d59d0 100644 --- a/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java +++ b/ic/src/private/nccloud/pubift/commen/impl/utils/HttpPostOtherSysImpl.java @@ -26,12 +26,12 @@ public class HttpPostOtherSysImpl implements IHttpPostOtherSys { private static final String CLIENT_TYPE = "S"; private static final String EP_ID = ""; private static final String LOGIN_URL = "/GTHINKING/AjaxService/N_MISPRO/100208057.ashx/Login"; - 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 tokenValue = this.getMESToken(mesip); 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 0dfa373..148ed08 100644 --- a/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java +++ b/ic/src/public/nccloud/pubift/commen/itf/utils/IHttpPostOtherSys.java @@ -24,5 +24,4 @@ public interface IHttpPostOtherSys { * ݵⲿϵͳ */ public void sendToExternalSystem(String apiPaht, Map requestData) throws BusinessException; - } diff --git a/so/src/private/nc/bs/so/m30/rule/approve/AfterApprovingSynchronizeRuleMES.java b/so/src/private/nc/bs/so/m30/rule/approve/AfterApprovingSynchronizeRuleMES.java new file mode 100644 index 0000000..af41f7e --- /dev/null +++ b/so/src/private/nc/bs/so/m30/rule/approve/AfterApprovingSynchronizeRuleMES.java @@ -0,0 +1,271 @@ +package nc.bs.so.m30.rule.approve; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +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.balatype.BalaTypeVO; +import nc.vo.bd.currtype.CurrtypeVO; +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.cmp.util.StringUtils; +import nc.vo.org.DeptVO; +import nc.vo.pub.BusinessException; +import nc.vo.pub.billtype.BilltypeVO; +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.so.m30.entity.SaleOrderVO; +import nc.vo.so.m30.entity.SaleOrderHVO; +import nc.vo.so.m30.entity.SaleOrderBVO; +import nc.vo.vorg.DeptVersionVO; +import nccloud.bs.sc.scadjust.beforeedit.rule.head.Psndoc; +import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; + +/** + * ۶MES˼άϵͳ + */ +public class AfterApprovingSynchronizeRuleMES implements IRule { + private static final String SALE_ORDER_URL = "/GTHINKING/AjaxService/N_XSSJJSA/102397000.ashx/XSDD_INSERT"; // ۶ͬӿ + private static final String logginfo = "OALOG"; + private static final Log obmlog = Log.getInstance(logginfo); + private static final BaseDAO dao = new BaseDAO(); + + public AfterApprovingSynchronizeRuleMES() { + } + + @Override + public void process(SaleOrderVO[] saleOrderVOs) { + try { + if (saleOrderVOs == null || saleOrderVOs.length == 0) { + return; + } + // ʼHTTP󹤾 + IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); + // ÿ۶ + for (SaleOrderVO saleOrderVO : saleOrderVOs) { + SaleOrderHVO head = saleOrderVO.getParentVO(); + SaleOrderBVO[] bodys = saleOrderVO.getChildrenVO(); + + // Ҫ͵ + JSONObject syncData = buildSyncData(head, bodys); + + if (syncData != null) { + // ݵ˼άϵͳ + httpPostOtherSys.sendToExternalSystem(SALE_ORDER_URL, syncData); + } + } + } catch (Exception e) { + obmlog.error("AfterApprovingSynchronizeRuleMES-쳣:" + e.getMessage(), e); + ExceptionUtils.wrappException(e); + } + } + + /** + * Ͻ˼άϵͳӿڹ淶 + */ + private JSONObject buildSyncData(SaleOrderHVO head, SaleOrderBVO[] bodys) throws BusinessException { + obmlog.debug("AfterApprovingSynchronizeRuleMES-ʼ۶: " + head.getVbillcode()); + // ֯͵ + if (!checkOrderValidForSync(head)) { + obmlog.debug("AfterApprovingSynchronizeRule-۶,Ϊ˵֯ǵ: " + head.getVbillcode()); + return null; + } + + // + JSONObject requestData = new JSONObject(); + JSONObject data = new JSONObject(); + // ۶ ﳬ Ϊֶ + data.put("orderNo", head.getVbillcode()); + // ͻ + data.put("customOrderNo", null); + // ڣʽΪYYYY-MM-DD + UFDate dbilldate = head.getDbilldate(); + data.put("orderDate", dbilldate != null ? dbilldate.toString().substring(0, 10) : null); + // 𣨷DZ + data.put("orderType", transferCodeByPk(BilltypeVO.TABLENAME, BilltypeVO.PK_BILLTYPECODE, BilltypeVO.PK_BILLTYPE_ID, head.getCtrantypeid())); + // ɷʽ + data.put("generation", "Z"); + // ͻ루󳤶8 + String customerCode = transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, + CustomerVO.PK_CUSTOMER, head.getCcustomerid()); + data.put("customId", customerCode); + data.put("seller", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.NAME, PsndocVO.PK_PSNDOC, head.getCemployeeid())); + // ۲ű루󳤶8 + String deptCode = transferCodeByPk(DeptVersionVO.getDefaultTableName(), DeptVersionVO.CODE, + DeptVersionVO.PK_VID, head.getCdeptvid()); + data.put("departmentId", deptCode); + // ϵˣDZ + data.put("contacts", null); + // ϵ绰DZ + data.put("contactNum", null); + // "X""S" ֻcode Ҫж + data.put("settlementType", transferCodeByPk(BalaTypeVO.getDefaultTableName(), BalaTypeVO.CODE, BalaTypeVO.PK_BALATYPE, head.getCbalancetypeid())); + // ң󳤶3 + String currencyCode = transferCodeByPk(CurrtypeVO.getDefaultTableName(), CurrtypeVO.CODE, CurrtypeVO.PK_CURRTYPE, head.getCorigcurrencyid()); + data.put("currency", currencyCode); + // DZֶһΪnull + data.put("priceListId", null); + data.put("invoicingUnit", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, head.getCinvoicecustid())); + data.put("contractNo", null); + data.put("projectNo", null); + data.put("salesAreaId", null); + data.put("deliveryAreaId", null); + data.put("discount", null); + data.put("paymentType", null); + data.put("warranty", null); + data.put("retentionAmount", null); + data.put("prepayment", null); + data.put("payment", null); + data.put("salesChannels", null); + data.put("transportMode", null); + data.put("transportProxy", null); + data.put("packing", null); + data.put("deliveryAddress", null); + data.put("labelDemand", null); + data.put("skillsDemand", null); + data.put("contractType", null); + data.put("deliveryRemarks", null); + data.put("remarks", head.getVnote()); + + // ϸ - ֶֻ + JSONArray details = new JSONArray(); + if (bodys != null) { + for (SaleOrderBVO body : bodys) { + JSONObject detailItem = new JSONObject(); + + // ֶҪֶ + // dreceivedate + UFDate dreceivedate = body.getDreceivedate(); + data.put("demandDate", dreceivedate != null ? dreceivedate.toString().substring(0, 10) : null); + // ƻ dsenddate + UFDate dsenddate = body.getDsenddate(); + data.put("deliveryDate", dsenddate != null ? dsenddate.toString().substring(0, 10) : null); + // nexchangerate + data.put("exchangeRate", body.getVchangerate() != null ? transferSpecialField(body.getVchangerate()) : null); + + + // ±ֶ + // + detailItem.put("sequenceNum", body.getCrowno()); + // ͬ + detailItem.put("contractNum", null); + // ϱ + String materialCode = transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, + MaterialVO.PK_MATERIAL, body.getCmaterialvid()); + detailItem.put("materialId", materialCode); + // λ + detailItem.put("unit", transferCodeByPk(MeasdocVO.getDefaultTableName(), MeasdocVO.CODE, MeasdocVO.PK_MEASDOC, body.getCunitid())); + // ϵ + detailItem.put("scaleFactor", body.getVchangerate() != null ? transferSpecialField(body.getVchangerate()) : null); + // ֵ˰ + UFDouble taxRate = body.getNtaxrate(); + detailItem.put("vatRate", taxRate != null ? taxRate.toString() : null); + // + UFDouble num = body.getNastnum(); + detailItem.put("quantity", num != null ? num.getDouble() : null); + // + UFDouble mainNum = body.getNnum(); + detailItem.put("mainQuantity", mainNum != null ? mainNum.getDouble() : null); + // ˰۸ + UFDouble taxPrice = body.getNqtorigtaxprice(); + detailItem.put("price", taxPrice != null ? taxPrice.getDouble() : null); + // ˰ + UFDouble taxAmount = body.getNorigtaxmny(); + detailItem.put("amount", taxAmount != null ? taxAmount.getDouble() : null); + // ˰ + UFDouble noTaxPrice = body.getNqtorigprice(); + detailItem.put("noTaxPrice", noTaxPrice != null ? noTaxPrice.getDouble() : null); + // ˰ + UFDouble noTaxAmount = body.getNorigmny(); + detailItem.put("noTaxAmount", noTaxAmount != null ? noTaxAmount.getDouble() : null); + UFDate dreceivedate1 = body.getDreceivedate(); + detailItem.put("demandDate", dreceivedate1 != null ? dreceivedate1.toString().substring(0, 10) : null); + UFDate dsenddate1 = body.getDsenddate(); + detailItem.put("deliveryDate", dsenddate1 != null ? dsenddate1.toString().substring(0, 10) : null); + // DZֶΪnull + detailItem.put("productNum", null); + detailItem.put("factoryId", null); + detailItem.put("customMtId", null); + detailItem.put("customNo", null); + detailItem.put("customSN", null); + detailItem.put("remarks", null); + + details.add(detailItem); + } + } + + data.put("DETAILS", details); + requestData.put("Data", data); + + return requestData; + } + + /** + * 鶩Ƿͬ + */ + private boolean checkOrderValidForSync(SaleOrderHVO head) { + if (!head.getPk_org().equals("0001A110000000000677")) { + obmlog.debug("AfterApprovingSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + head.getVbillcode()); + return true; + } + return false; + } + + /** + * תֶ 1/1 תΪС 1.0 + */ + + private String transferSpecialField(String field) { + if (field == null || field.trim().isEmpty()) { + return null; + } + String[] split = field.split("/"); + if (split.length == 2) { + String numStr = split[0].trim(); + String denStr = split[1].trim(); + + if (denStr.equals("0")) { + return "0.00"; // ĸΪ + } + + try { + BigDecimal numerator = new BigDecimal(numStr); + BigDecimal denominator = new BigDecimal(denStr); + return numerator.divide(denominator, 2, RoundingMode.HALF_UP).toString(); + } catch (NumberFormatException e) { + return field; // Ƿ֣ԭֶ + } + } + return field; + } + + /** + * ѯ + */ + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if (pk == null || pk.trim().isEmpty()) { + 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/so/src/private/nc/impl/so/m30/action/main/ApproveSaleOrderAction.java b/so/src/private/nc/impl/so/m30/action/main/ApproveSaleOrderAction.java new file mode 100644 index 0000000..e99572b --- /dev/null +++ b/so/src/private/nc/impl/so/m30/action/main/ApproveSaleOrderAction.java @@ -0,0 +1,223 @@ +package nc.impl.so.m30.action.main; + +import nc.bs.framework.common.NCLocator; +import nc.bs.pub.action.N_30_APPROVE; +import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; +import nc.bs.so.m30.maintain.rule.delete.RewritePromotePriceDeleteRule; +import nc.bs.so.m30.plugin.Action30PlugInPoint; +import nc.bs.so.m30.rule.approve.*; +import nc.bs.so.m30.rule.atp.SaleOrderVOATPAfterRule; +import nc.bs.so.m30.rule.atp.SaleOrderVOATPBeforeRule; +import nc.bs.so.m30.rule.credit.RenovateARByHidsBeginRule; +import nc.bs.so.m30.rule.credit.RenovateARByHidsEndRule; +import nc.bs.so.m30.rule.m35.ArsubOffsetAfterApproveRule; +import nc.bs.so.m30.rule.me.SaleOrderVOApproveAfterRule; +import nc.impl.pubapp.pattern.data.bill.BillQuery; +import nc.impl.pubapp.pattern.data.vo.VOUpdate; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +import nc.itf.scmpub.reference.uap.group.SysInitGroupQuery; +import nc.vo.credit.engrossmaintain.pub.action.M30EngrossAction; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pubapp.AppContext; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.log.TimeLog; +import nc.vo.scmpub.msg.rule.UpdateMsgStatusRule; +import nc.vo.scmpub.res.billtype.SOBillType; +import nc.vo.scmpub.util.AppInfoContext; +import nc.vo.so.m30.entity.SaleOrderBVO; +import nc.vo.so.m30.entity.SaleOrderHVO; +import nc.vo.so.m30.entity.SaleOrderVO; +import nc.vo.so.pub.enumeration.BillStatus; +import nc.vo.so.pub.rule.SOPfStatusChgRule; +import nccloud.bs.so.mobile.saleorder.operation.rule.MobAfterApproveMessageRule; +import nccloud.commons.lang.ArrayUtils; +import nccloud.nc.vo.pub.pf.BusFlowInfoVO; +import nccloud.pubitf.riart.businesstype.IPFBusinessTypeService; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ApproveSaleOrderAction { + public ApproveSaleOrderAction() { + } + + public Object approve(SaleOrderVO[] bills, N_30_APPROVE script) { + Object ret = null; + + try { + AroundProcesser processer = new AroundProcesser(Action30PlugInPoint.ApproveAction); + TimeLog.logStart(); + this.setAppInfoContext(); + this.addBeforeRule(processer); + processer.before(bills); + TimeLog.info(NCLangRes4VoTransl.getNCLangRes().getStrByID("4006011_0", "04006011-0162")); + ret = script.procActionFlow(script.getPfParameterVO()); + SaleOrderVO[] newbills = script.getVos(); + this.updateNewBillStatus(newbills); + TimeLog.logStart(); + Integer newbillstatus = newbills[0].getParentVO().getFstatusflag(); + String ctranstype = newbills[0].getParentVO().getVtrantypecode(); + this.addAfterRule(processer, newbillstatus, ctranstype); + processer.after(newbills); + TimeLog.info(NCLangRes4VoTransl.getNCLangRes().getStrByID("4006011_0", "04006011-0163")); + String[] pk_so_sales = new String[0]; + + for (SaleOrderVO svo : newbills) { + pk_so_sales = (String[]) ArrayUtils.add(pk_so_sales, svo.getParentVO().getCsaleorderid()); + } + + newbills = (SaleOrderVO[]) (new BillQuery(SaleOrderVO.class)).query(pk_so_sales); + if (null == ret) { + ret = newbills; + } + } catch (Exception ex) { + ExceptionUtils.wrappException(ex); + } + + return ret; + } + + private void updateNewBillStatus(SaleOrderVO[] newbills) { + new HashMap(); + List pk_org = new ArrayList(); + + for (SaleOrderVO vo : newbills) { + for (SaleOrderBVO bvo : vo.getChildrenVO()) { + String csettleorgid = bvo.getCsettleorgid(); + if (!pk_org.contains(csettleorgid)) { + pk_org.add(csettleorgid); + } + } + } + + Map isEnable = SysInitGroupQuery.isRMEnabled(pk_org); + + for (SaleOrderVO vo : newbills) { + List newbvo = new ArrayList(); + + for (SaleOrderBVO bvo : vo.getChildrenVO()) { + String csettleorgid = bvo.getCsettleorgid(); + if (!isEnable.isEmpty() && !(Boolean) isEnable.get(csettleorgid)) { + bvo.setRmcontractbflag(UFBoolean.TRUE); + } else { + newbvo.add(bvo); + } + } + } + + SOPfStatusChgRule statuschgrule = new SOPfStatusChgRule(); + SaleOrderHVO[] updateheads = new SaleOrderHVO[newbills.length]; + List listbody = new ArrayList(); + int i = 0; + + for (SaleOrderVO ordervo : newbills) { + statuschgrule.changePfToBillStatus(ordervo); + updateheads[i++] = ordervo.getParentVO(); + + for (SaleOrderBVO bvo : ordervo.getChildrenVO()) { + listbody.add(bvo); + } + } + + String[] headupname = new String[]{"fstatusflag"}; + VOUpdate headupsrv = new VOUpdate(); + headupsrv.update(updateheads, headupname); + String[] bodyupname = new String[]{"frowstatus", "rmcontractbflag"}; + VOUpdate bodyupsrv = new VOUpdate(); + SaleOrderBVO[] updatebodys = (SaleOrderBVO[]) listbody.toArray(new SaleOrderBVO[listbody.size()]); + bodyupsrv.update(updatebodys, bodyupname); + } + + private void addAfterRule(AroundProcesser processer, Integer newbillstatus, String ctranstype) { + IRule rule = null; + if (SysInitGroupQuery.isCREDITEnabled()) { + IRule var6 = new RenovateARByHidsEndRule(M30EngrossAction.M30Approve); + processer.addAfterRule(var6); + } + + boolean icEnable = SysInitGroupQuery.isICEnabled(); + if (icEnable) { + IRule var7 = new SaleOrderVOATPAfterRule(); + processer.addAfterRule(var7); + } + + IRule var8 = new ArsubOffsetAfterApproveRule(); + processer.addAfterRule(var8); + if (BillStatus.AUDIT.equalsValue(newbillstatus)) { + IRule var9 = new ApproveStateRule(); + processer.addAfterRule(var9); + if (this.isExistDelivery(ctranstype)) { + processer.addAfterRule(new SendMsgToDeliveryRule()); + } + } + + if (BillStatus.NOPASS.equalsValue(newbillstatus) && SysInitGroupQuery.isPRICEEnabled()) { + IRule var10 = new RewritePromotePriceDeleteRule(); + processer.addAfterRule(var10); + } + + IRule var11 = new SaleOrderVOApproveAfterRule(); + processer.addAfterRule(var11); + processer.addAfterRule(new MobAfterApproveMessageRule()); + processer.addAfterRule(new SaleOrderCreateRmBeforeRule()); + // ͵MESϵͳ + processer.addAfterRule(new AfterApprovingSynchronizeRuleMES()); + } + + private boolean isExistDelivery(String ctranstype) { + IPFBusinessTypeService pfservice = (IPFBusinessTypeService) NCLocator.getInstance().lookup(IPFBusinessTypeService.class); + BusFlowInfoVO[] refbillinfos = null; + String groupId = AppContext.getInstance().getPkGroup(); + String userId = AppContext.getInstance().getPkUser(); + + try { + refbillinfos = pfservice.getDownstreamInfo(SOBillType.Order.getCode(), ctranstype, groupId, userId, true); + String delieverycode = SOBillType.Delivery.getCode(); + + for (BusFlowInfoVO info : refbillinfos) { + if (delieverycode.equals(info.getBilltype())) { + return true; + } + } + + return false; + } catch (BusinessException e) { + ExceptionUtils.wrappException(e); + return false; + } + } + + private void addBeforeRule(AroundProcesser processer) { + IRule rule = new VOSagaFrozenValidateRule(); + processer.addBeforeRule(rule); + IRule var4 = new CheckApprovableRule(); + processer.addBeforeRule(var4); + if (SysInitGroupQuery.isCREDITEnabled()) { + IRule var5 = new RenovateARByHidsBeginRule(M30EngrossAction.M30Approve); + processer.addBeforeRule(var5); + } + + boolean icEnable = SysInitGroupQuery.isICEnabled(); + if (icEnable) { + IRule var6 = new SaleOrderVOATPBeforeRule(); + processer.addBeforeRule(var6); + } + + IRule var7 = new BusiLog(); + processer.addBeforeRule(var7); + processer.addBeforeRule(new UpdateMsgStatusRule("csaleorderid")); + } + + private void setAppInfoContext() { + String buttonCode = AppInfoContext.getBtnCode(); + if ("".equals(buttonCode) || null == buttonCode) { + AppInfoContext.setBtnCode("appoveCenter"); + } + + } +} From 5884103604e86402ab9ddde91f471dcdc48756d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= <125556714+Topfunplus@users.noreply.github.com> Date: Wed, 21 May 2025 12:55:43 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E9=94=80=E5=94=AE=E4=BA=A4=E8=B4=A7?= =?UTF-8?q?=E5=8D=95=E5=AE=8C=E5=96=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sign/rule/SalesDeliveryOrderRuleMES.java | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java index 59bada9..eef5f1c 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/SalesDeliveryOrderRuleMES.java @@ -90,34 +90,29 @@ public class SalesDeliveryOrderRuleMES implements IRule { // - ֶδ // ֶ info.put("orderNo", hvo.getVbillcode()); //  - info.put("orderDate", hvo.getDbilldate() == null ? null : hvo.getDbilldate().toString().substring(0, 10)); // TODO ڣʽyyyy-MM-dd - info.put("deliveryDate", hvo.getDbilldate() == null ? null : hvo.getDbilldate().toString().substring(0, 10)); //  TODO ƻڣõ + info.put("orderDate", hvo.getDbilldate() == null ? null : hvo.getDbilldate().toString().substring(0, 10)); + info.put("deliveryDate", hvo.getDbilldate() == null ? null : hvo.getDbilldate().toString().substring(0, 10)); // ͻID - ͻ(ccustomerid) info.put("customId", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, hvo.getCcustomerid())); // ͻ // Ʊλ - info.put("invoicingUnit", null); // TODO Ʊλ룬޶Ӧֶ + info.put("invoicingUnit", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, hvo.getCcustomervid())); // ۲ű info.put("departmentId", transferCodeByPk(DeptVersionVO.getDefaultTableName(), DeptVersionVO.CODE, DeptVersionVO.PK_VID, hvo.getCdptvid())); // ۲ű - - // Ա info.put("seller", transferCodeByPk(PsndocVO.getDefaultTableName(), - PsndocVO.CODE, PsndocVO.PK_PSNDOC, hvo.getCbiztype())); // TODO Ա - - info.put("exchangeRate", null); // TODO ʣ޶Ӧֶ ۳Ҳû + PsndocVO.NAME, PsndocVO.PK_PSNDOC, hvo.getCbizid())); info.put("invoicingBasis", "S"); // Ʊ - info.put("settlementType", null); // TODO 㷽ʽ޶Ӧֶ - + info.put("settlementType", "S"); // 㷽ʽ // ֿ info.put("warehouseId", transferCodeByPk(RackVO.getDefaultTableName(), RackVO.CODE, RackVO.PK_RACK, hvo.getCwarehouseid())); // ֿ - info.put("type", "XSJH"); // ͣ۽ - info.put("genType", null); // TODO ɷʽ޶Ӧֶ - info.put("returned", null); // TODO Ƿ˻޶Ӧֶ - + // ɷʽ + info.put("genType", "S"); + // Ƿ˻ + info.put("returned", "N"); // DZֶ info.put("transportMode", null); // ䷽ʽ info.put("deliveryAddress", null); // ջص @@ -135,30 +130,27 @@ public class SalesDeliveryOrderRuleMES implements IRule { for (SaleOutBodyVO bvo : bvos) { JSONObject detail = new JSONObject(); // ͷֶҪֶ + //  + info.put("exchangeRate", bvo.getNchangestdrate()); // ұ info.put("currency", transferCodeByPk(CurrtypeVO.getDefaultTableName(), CurrtypeVO.CODE, CurrtypeVO.PK_CURRTYPE, bvo.getCorigcurrencyid())); - // ֶ detail.put("orderNo", hvo.getVbillcode()); //  - detail.put("orderSn", bvo.getCrowno()); // TODO - + detail.put("orderSn", bvo.getCrowno()); //  // ɷʽΪʱ - detail.put("soOrderNo", bvo.getVsourcebillcode()); // TODO ۶ - detail.put("soSequenceNum", bvo.getVsourcerowno()); // TODO ۶ - + detail.put("soOrderNo", bvo.getVsourcebillcode()); // ۶ + detail.put("soSequenceNum", bvo.getVsourcerowno()); // ۶ // ϱ detail.put("materialId", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, bvo.getCmaterialoid())); // ϱ - // λ detail.put("unit", transferCodeByPk(MeasdocVO.getDefaultTableName(), MeasdocVO.CODE, MeasdocVO.PK_MEASDOC, bvo.getCunitid())); // λ - detail.put("scaleFactor", transferSpecialField(bvo.getVchangerate())); // ϵ detail.put("taxRate", bvo.getNtaxrate()); // ˰ detail.put("recQty", bvo.getNshouldassistnum()); // Ӧ - detail.put("mainRecQty", bvo.getNshouldnum()); // TODO Ӧ + detail.put("mainRecQty", bvo.getNnum()); // Ӧ // DZֶ detail.put("batchNum", null); // @@ -168,15 +160,12 @@ public class SalesDeliveryOrderRuleMES implements IRule { detail.put("amountIncludeTax", null); // ԭҺ˰ detail.put("taxAmount", null); // ˰ detail.put("remark", null); // ע - details.add(detail); } } info.put("Details", details); - // infoӵ requestData.put("Data", info); - return requestData; }