diff --git a/erm/component.xml b/erm/component.xml new file mode 100644 index 0000000..e7b647f --- /dev/null +++ b/erm/component.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/erm/src/client/nccloud/web/erm/action/billmanage/BillQueryAction.java b/erm/src/client/nccloud/web/erm/action/billmanage/BillQueryAction.java new file mode 100644 index 0000000..d9dba5a --- /dev/null +++ b/erm/src/client/nccloud/web/erm/action/billmanage/BillQueryAction.java @@ -0,0 +1,140 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.web.erm.action.billmanage; + +import com.alibaba.fastjson.JSONObject; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import nc.bs.logging.Log; +import nc.nccloud.util.erm.expenseaccount.Func; +import nc.vo.ep.bx.JKBXHeaderVO; +import nc.vo.ml.NCLangRes4VoTransl; +import nccloud.dto.baseapp.querytree.dataformat.Condition; +import nccloud.dto.baseapp.querytree.dataformat.PageInfo; +import nccloud.dto.baseapp.querytree.dataformat.QueryCondition; +import nccloud.dto.baseapp.querytree.dataformat.QueryTreeFormatVO; +import nccloud.dto.baseapp.querytree.dataformat.Value; +import nccloud.framework.core.exception.ExceptionUtils; +import nccloud.framework.core.json.IJson; +import nccloud.framework.service.ServiceLocator; +import nccloud.framework.web.container.IRequest; +import nccloud.framework.web.json.JsonFactory; +import nccloud.framework.web.ui.model.row.Row; +import nccloud.framework.web.ui.pattern.grid.Grid; +import nccloud.framework.web.ui.pattern.grid.GridOperator; +import nccloud.pubitf.erm.billmanage.IBillManageService; +import nccloud.web.erm.action.lic.AbstractLicAction; +import nccloud.web.erm.util.expenseaccount.initbills.InitBillsUtil; +import org.apache.commons.lang3.StringUtils; + +public class BillQueryAction extends AbstractLicAction { + private Log log = Log.getInstance(this.getClass()); + + public BillQueryAction() { + } + + public Object doRealAction(IRequest request) { + JKBXHeaderVO[] jkbxvos = new JKBXHeaderVO[0]; + Grid grid = new Grid(); + PageInfo pageInfo = null; + + try { + if (request == null) { + ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("20110011makebill", "020110011makebill-0000")); + } + + IJson json = JsonFactory.create(); + String read = request.read(); + if (StringUtils.isEmpty(read)) { + ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("20110011makebill", "020110011makebill-0000")); + } + + QueryTreeFormatVO info = (QueryTreeFormatVO)json.fromJson(read, QueryTreeFormatVO.class); + if (null == info) { + ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("20110011makebill", "020110011makebill-0000")); + } + + if (info.getUserdefObj() != null) { + QueryCondition queryCon = new QueryCondition(); + List conditions = new ArrayList(); + + for(Map.Entry entry : info.getUserdefObj().entrySet()) { + Condition con = new Condition(); + con.setField((String)entry.getKey()); + Value value = new Value(); + value.setFirstvalue((String)entry.getValue()); + con.setValue(value); + conditions.add(con); + } + + queryCon.setConditions(conditions); + info.setQuerycondition(queryCon); + } + + IBillManageService billManageService = (IBillManageService)ServiceLocator.find(IBillManageService.class); + String[] pks = null; + if (info.getQuerycondition() != null) { + jkbxvos = (JKBXHeaderVO[])billManageService.queryBillInfoByPage(info).toArray(jkbxvos); + } else { + ExceptionUtils.wrapBusinessException("请传入查询条件"); + } + + if (jkbxvos == null || jkbxvos.length == 0) { + return null; + } + + pks = new String[jkbxvos.length]; + + for(int i = 0; i < jkbxvos.length; ++i) { + if (jkbxvos[i] != null) { + pks[i] = jkbxvos[i].getPk_jkbx(); + } + } + + GridOperator go = new GridOperator("201104DJCX_LIST"); + grid = go.toGrid(jkbxvos); + InitBillsUtil.proGridDigit(grid); + this.proGridDjztAndSpr(grid, pks); + pageInfo = info.getPageInfo(); + } catch (Exception e) { + this.log.error(e); + ExceptionUtils.wrapException(e); + } + + JSONObject jsonObj = new JSONObject(); + jsonObj.put("pageInfo", pageInfo); + jsonObj.put("data", grid); + return jsonObj; + } + + private void proGridDjztAndSpr(Grid grid, String[] pks) throws Exception { + IBillManageService service = (IBillManageService)ServiceLocator.find(IBillManageService.class); + Map busiid_username = service.qryCurApproveman(Arrays.asList(pks)); + Row[] rows = grid.getModel().getRows(); + + for(int i = 0; i < rows.length; ++i) { + String pk_billtype = Func.toString(rows[i].getCell("pk_billtype").getValue()); + String djlxbm = Func.toString(rows[i].getCell("djlxbm").getValue()); + if (!"264a".equalsIgnoreCase(djlxbm) && !"261X".equalsIgnoreCase(pk_billtype) && !"262X".equalsIgnoreCase(pk_billtype)) { + if ("3".equals(Func.toString(rows[i].getCell("djzt").getValue()))) { + rows[i].getCell("djzt").setDisplay(NCLangRes4VoTransl.getNCLangRes().getStrByID("20110012billmanage", "020110012billmanage-0002")); + } + } else if ("3".equals(Func.toString(rows[i].getCell("djzt").getValue()))) { + rows[i].getCell("djzt").setDisplay(NCLangRes4VoTransl.getNCLangRes().getStrByID("20110012billmanage", "020110012billmanage-0000")); + } + + if (busiid_username != null && busiid_username.size() > 0) { + String pk_jkbx = Func.toString(rows[i].getCell("pk_jkbx").getValue()); + if (!StringUtils.isEmpty((CharSequence)busiid_username.get(pk_jkbx))) { + rows[i].getCell("approver").setDisplay((String)busiid_username.get(pk_jkbx)); + } + } + } + + } +} diff --git a/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java b/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java index e05334f..e291e10 100644 --- a/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java +++ b/mmpac/src/public/nccloud/openapi/mmpac/wr/WrResource.java @@ -136,6 +136,17 @@ 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); + //뱨 + BaseDAO baseDAO = new BaseDAO(); + 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.saveAndApprove(voList.toArray(new AggWrVO[0])); boolean successFlag = true; StringBuilder errMsg = new StringBuilder(); diff --git a/mmpsc/src/private/nc/bs/mmpsc/pscsettle/bp/SettleApproveBP.java b/mmpsc/src/private/nc/bs/mmpsc/pscsettle/bp/SettleApproveBP.java index 2e95bc6..81e44da 100644 --- a/mmpsc/src/private/nc/bs/mmpsc/pscsettle/bp/SettleApproveBP.java +++ b/mmpsc/src/private/nc/bs/mmpsc/pscsettle/bp/SettleApproveBP.java @@ -11,6 +11,7 @@ import nc.bs.mmpsc.pscsettle.rule.SettleStatusUpdateRule; import nc.bs.mmpsc.pscsettle.rule.approve.FillAuditInfoRule; import nc.bs.mmpsc.pscsettle.rule.unapprove.FilterAdjustedRule; import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule; +import nc.bs.mmpub.rule.MMVOToAPRule; import nc.impl.pubapp.pattern.data.bill.template.UpdateBPTemplate; import nc.impl.pubapp.pattern.rule.IFilterRule; import nc.impl.pubapp.pattern.rule.IRule; @@ -30,6 +31,9 @@ public class SettleApproveBP { } private void addAfterRule(CompareAroundProcesser processer, AggSettleVO[] originBills) { + + IRule var5 = new MMVOToAPRule(originBills); + processer.addAfterRule(var5); } private void addBeforeRule(CompareAroundProcesser processer) { diff --git a/mmpsc/src/public/nc/bs/mmpub/rule/MMVOToAPRule.java b/mmpsc/src/public/nc/bs/mmpub/rule/MMVOToAPRule.java new file mode 100644 index 0000000..fb5fcf1 --- /dev/null +++ b/mmpsc/src/public/nc/bs/mmpub/rule/MMVOToAPRule.java @@ -0,0 +1,36 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nc.bs.mmpub.rule; + +import nc.bs.mmpsc.pscsettle.bp.SettleToAPBP; +import nc.impl.pubapp.pattern.data.vo.tool.VOConcurrentTool; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.util.mmf.framework.base.MMArrayUtil; +import nc.vo.mmpsc.pscsettle.entity.AggSettleVO; + +public class MMVOToAPRule implements IRule { + + public MMVOToAPRule(AggSettleVO[] originBills) { + } + + + + public void process(AggSettleVO[] vos) { + if (!MMArrayUtil.isEmpty(vos)) { + (new VOConcurrentTool()).checkTSWithDB(vos[0].getItemVO()); + SettleToAPBP bp = new SettleToAPBP(); + AggSettleVO[] retBills = bp.toAP(vos); + if (retBills.length>0){ + System.out.println(1); + } + + } + } + + protected String getCheckField() { + return null; + } +} diff --git a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java index ac275d6..a5bf14b 100644 --- a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java +++ b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java @@ -320,17 +320,24 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (null == originVos || originVos.length == 0) { ExceptionUtils.wrappBusinessException("ݴδƥ䵽"); } - Map delMap = new HashMap<>(); + Map> delBipMap = new HashMap<>(); for (Map objectMap : paramList) { Map headdata = (Map) objectMap.get(HEADTABLE); - delMap.put(headdata.get("csaleorderid") + "", headdata.getOrDefault("delId", "") + ""); + String csaleorderid = headdata.get("csaleorderid") + ""; List bodyArr = (List) objectMap.get(BODYTABLE); + List delIds = new ArrayList<>(); for (Object body : bodyArr) { Map bodydata = (Map) body; if ((bodydata.getOrDefault("vbdef11", "") + "").isEmpty()) { // vbdef11ΪΪ bodydata.put("status", "add"); } + if (!(bodydata.getOrDefault("csaleorderbid", "") + "").isEmpty()) { + delIds.add(bodydata.get("csaleorderbid") + ""); + } + } + if (!delIds.isEmpty()) { + delBipMap.put(csaleorderid, delIds); } } @@ -356,20 +363,17 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { SaleOrderVO bipVo = vosMap.get(primaryKey); // õ״̬ hvo.setStatus(VOStatus.UPDATED); - String delId = delMap.get(primaryKey); + List bipIds = delBipMap.get(primaryKey); // ȽcombinBillVOsеBVOvosеBVO for (SaleOrderBVO bvo : vo.getChildrenVO()) { - bvo.setStatus(VOStatus.UPDATED); + bvo.setStatus(VOStatus.DELETED); String csaleorderbid = bvo.getCsaleorderbid(); - // ɾе״̬,bipҲ - if (StringUtils.isNotEmpty(delId)) { - String[] delIds = delId.split(",", -1); - String vbdef11 = bvo.getVbdef11(); - // BIPͬ۶ɾУΪɾ״̬ - if (Arrays.asList(delIds).contains(vbdef11)) { - bvo.setStatus(VOStatus.DELETED); - NCCForUAPLogger.debug("findDeletedBids:" + VOStatus.DELETED + ",csaleorderbid = " + csaleorderbid); + // е״̬,bipҵ޸ + if (bipIds != null && !bipIds.isEmpty()) { + // ϸΪ޸״̬ + if (bipIds.contains(csaleorderbid)) { + bvo.setStatus(VOStatus.UPDATED); } } } diff --git a/so/src/public/nccloud/openapi/so/m30/SaleOrderResource.java b/so/src/public/nccloud/openapi/so/m30/SaleOrderResource.java index 9a29d48..44b1aac 100644 --- a/so/src/public/nccloud/openapi/so/m30/SaleOrderResource.java +++ b/so/src/public/nccloud/openapi/so/m30/SaleOrderResource.java @@ -508,4 +508,47 @@ public class SaleOrderResource extends NCCPubRestResource { } } + /** + * ͬϵͳ޸ERP۶ϸ + * + * @author mzr + * @date 2025/05/28 + */ + @POST + @Path("updateDefs") + @Consumes({"application/json"}) + @Produces({"application/json"}) + public JSONString updateDefs(List> paramList) { + int num = 0; + try { + for (Map paramMap : paramList) { + String csaleorderbid = (String) paramMap.get("csaleorderbid"); + if (StringUtils.isEmpty(csaleorderbid)) { + return ResultMessageUtil.exceptionToJSON("Ϊ,", APIErrCodeEnum.BUSINESSEXCCODE.getCode()); + } + StringBuilder sql = new StringBuilder("update so_saleorder_b set "); + SQLParameter parameter = new SQLParameter(); + for (Map.Entry entry : paramMap.entrySet()) { + if (!"csaleorderbid".equals(entry.getKey())) { + sql.append(entry.getKey()).append(" = ?, "); + parameter.addParam(entry.getValue()); + } + } + if (parameter.getCountParams() <= 0) { + return ResultMessageUtil.toJSON("Ϊ,", APIErrCodeEnum.BUSINESSEXCCODE.getCode()); + } + // ɾ", " + sql.delete(sql.length() - 2, sql.length()); + sql.append(" where csaleorderbid = ?"); + parameter.addParam(csaleorderbid); + BaseDAO baseDAO = new BaseDAO(); + num += baseDAO.executeUpdate(sql.toString(), parameter); + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return ResultMessageUtil.toJSON(num, "۶޸ijɹ,޸" + num + ""); + + } + } diff --git a/sscivm/src/client/nccloud/web/sscivm/ivsale/sale/action/InvoiceDownloadAction.java b/sscivm/src/client/nccloud/web/sscivm/ivsale/sale/action/InvoiceDownloadAction.java index 4257141..32c8ce0 100644 --- a/sscivm/src/client/nccloud/web/sscivm/ivsale/sale/action/InvoiceDownloadAction.java +++ b/sscivm/src/client/nccloud/web/sscivm/ivsale/sale/action/InvoiceDownloadAction.java @@ -230,12 +230,12 @@ public class InvoiceDownloadAction implements ICommonAction { private String doGet(String requestUrl, Map paramMap) throws IOException { PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); - cm.setMaxTotal(500); - cm.setDefaultMaxPerRoute(50); + cm.setMaxTotal(5000); + cm.setDefaultMaxPerRoute(500); - RequestConfig globalConfig = RequestConfig.custom().setConnectionRequestTimeout(5000) // ӳػȡӳʱ - .setConnectTimeout(5000) // ӽʱ - .setSocketTimeout(20000) // ȴӦʱ + RequestConfig globalConfig = RequestConfig.custom().setConnectionRequestTimeout(50000) // ӳػȡӳʱ + .setConnectTimeout(50000) // ӽʱ + .setSocketTimeout(200000) // ȴӦʱ .setCookieSpec(CookieSpecs.IGNORE_COOKIES).build(); CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm) diff --git a/uapbd/src/private/nc/bs/uapbd/bip/workplugin/ErpSaleOrderToBIPBackgroupWorkPlugin.java b/uapbd/src/private/nc/bs/uapbd/bip/workplugin/ErpSaleOrderToBIPBackgroupWorkPlugin.java index 5e39968..5a7efe2 100644 --- a/uapbd/src/private/nc/bs/uapbd/bip/workplugin/ErpSaleOrderToBIPBackgroupWorkPlugin.java +++ b/uapbd/src/private/nc/bs/uapbd/bip/workplugin/ErpSaleOrderToBIPBackgroupWorkPlugin.java @@ -125,22 +125,7 @@ public class ErpSaleOrderToBIPBackgroupWorkPlugin implements IBackgroundWorkPlug // ȡδͺͬ۶µ۷ƱϢ - String sql = " select '1' as flag,so_saleinvoice_b.cfirstbid,csaleinvoicebid " + - "from so_saleinvoice,so_saleinvoice_b " + - "where so_saleinvoice.csaleinvoiceid=so_saleinvoice_b.csaleinvoiceid " + - "and so_saleinvoice.fstatusflag=2 " + - "and nvl(so_saleinvoice_b.vbdef10,'N') in ('~','N') " + - "and nvl(so_saleinvoice.vdef13,'~') not in ('~') " + - "union all " + - "select " + - "'2' as flag, " + - "ic_saleout_b.cfirstbillbid as cfirstbid, " + - "ic_saleout_b.cgeneralbid as csaleinvoicebid " + - "from ic_saleout_h, " + - "ic_saleout_b " + - "where ic_saleout_h.cgeneralhid = ic_saleout_b.cgeneralhid " + - "and nvl(ic_saleout_b.vbdef4,'N') in ('~','N') " + - "and ic_saleout_b.cfirsttype = '30'"; + String sql = " select * from v_bip_so_cron"; List> l_pk = (List>) new BaseDAO().executeQuery(sql.toString(), new MapListProcessor()); if (l_pk.isEmpty()) { diff --git a/uapbd/src/private/nccloud/api/impl/mmbd/bom/APIBomBusinessServiceImpl.java b/uapbd/src/private/nccloud/api/impl/mmbd/bom/APIBomBusinessServiceImpl.java index 86fbae3..30ccfcd 100644 --- a/uapbd/src/private/nccloud/api/impl/mmbd/bom/APIBomBusinessServiceImpl.java +++ b/uapbd/src/private/nccloud/api/impl/mmbd/bom/APIBomBusinessServiceImpl.java @@ -1,21 +1,15 @@ package nccloud.api.impl.mmbd.bom; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; +import nc.bs.dao.BaseDAO; import nc.bs.framework.common.InvocationInfoProxy; import nc.bs.framework.common.NCLocator; import nc.itf.bd.bom.bom0202.IBomBillMaintainService; import nc.itf.bd.bom.bom0202.IBomBillQueryService; -import nc.itf.bd.bom.bom0202.IBomBusinessService; import nc.itf.mmf.busi.measure.IMeasesureService; import nc.itf.uif.pub.IUifService; +import nc.jdbc.framework.SQLParameter; +import nc.jdbc.framework.processor.ColumnProcessor; import nc.mmbd.utils.factoryparam.MMBDFactoryParameter; import nc.pubitf.uapbd.IMaterialPubService; import nc.pubitf.uapbd.IMaterialPubService_C; @@ -27,23 +21,8 @@ import nc.util.mmf.busi.measure.MeasureVO; import nc.util.mmf.busi.measure.NumScaleUtil; import nc.util.mmf.busi.service.OrgUnitPubService; import nc.util.mmf.framework.base.MMValueCheck; -import nc.vo.bd.bom.bom0202.entity.AggBomVO; -import nc.vo.bd.bom.bom0202.entity.BomActivityVO; -import nc.vo.bd.bom.bom0202.entity.BomItemSourceVO; -import nc.vo.bd.bom.bom0202.entity.BomItemVO; -import nc.vo.bd.bom.bom0202.entity.BomLossVO; -import nc.vo.bd.bom.bom0202.entity.BomOutputsVO; -import nc.vo.bd.bom.bom0202.entity.BomPosVO; -import nc.vo.bd.bom.bom0202.entity.BomReplVO; -import nc.vo.bd.bom.bom0202.entity.BomSelectVO; -import nc.vo.bd.bom.bom0202.entity.BomUseOrgVO; -import nc.vo.bd.bom.bom0202.entity.BomVO; -import nc.vo.bd.bom.bom0202.entity.BomWipVO; -import nc.vo.bd.bom.bom0202.enumeration.BackflushTimeEnum; -import nc.vo.bd.bom.bom0202.enumeration.BackflushTypeEnum; -import nc.vo.bd.bom.bom0202.enumeration.BomCategoryEnum; -import nc.vo.bd.bom.bom0202.enumeration.BomTypeEnum; -import nc.vo.bd.bom.bom0202.enumeration.VersionTypeEnum; +import nc.vo.bd.bom.bom0202.entity.*; +import nc.vo.bd.bom.bom0202.enumeration.*; import nc.vo.bd.bom.bom0202.paramvo.BomHeadMtrlParam; import nc.vo.bd.bom.bom0202.paramvo.BomHeadMtrlResult; import nc.vo.bd.bom.bom0202.paramvo.BomMaterialParam; @@ -67,7 +46,15 @@ import nccloud.api.rest.utils.ResultMessageUtil; import nccloud.vo.bd.bom.bom0202.validate.BomSavingValidation; import org.json.JSONString; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + public class APIBomBusinessServiceImpl implements IAPIBomBusinessService { + + // 2025528 ֯˼άBOM汾Զ㴦 + private static final BaseDAO DAO = new BaseDAO(); + private static String HEADTABLE = "bd_bom"; private static String BODYTABLE = "bd_bom_b"; @@ -155,6 +142,10 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService { } // zhangxinah з dealWithMaterial(agg); + + // 2025528 ֯˼άBOM汾Զ㴦 By maolei + handleCableOrgJinSiWeiBomVersion(agg); + dataSupplement(agg, userCode); UFBoolean flag = (UFBoolean) agg.getParent().getAttributeValue("hbdefault"); @@ -1526,4 +1517,96 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService { item.setPk_useorg_v((String) agg.getParentVO().getAttributeValue("pk_org_v")); } } + + + private void handleCableOrgJinSiWeiBomVersion(AggBomVO agg) { + try { + String pk_org = (String) agg.getParent().getAttributeValue("pk_org"); + String hcmaterialid = (String) agg.getParent().getAttributeValue("hcmaterialid"); + String hversion = agg.getParent().getAttributeValue("hversion").toString(); + String cbomid = (String) agg.getParent().getAttributeValue("cbomid"); + String hvnote = (String) agg.getParent().getAttributeValue("hvnote"); + + // Ҫֶ + if (MMValueCheck.isEmpty(hcmaterialid) || MMValueCheck.isEmpty(hversion)) { + return; + } + + // жǷΪ֯֯C034ұע"˼ά" + boolean isCableOrgJinSiWei = isCableOrganizationWithJinSiWei(pk_org, hvnote); + + if (isCableOrgJinSiWei) { + // 汾 + String calculatedVersion = calculateBomVersion(pk_org, hcmaterialid ); + agg.getParent().setAttributeValue("hversion", calculatedVersion); + } + } catch (Exception e) { + ExceptionUtils.wrappBusinessException("ͬ֯˼άBOM汾Ŵ쳣" + e.getMessage()); + } + } + + /** + * жǷΪ֯ұע˼ά + * @param pk_org ֯ + * @param hvnote עϢ + * @return Ƿ + */ + private boolean isCableOrganizationWithJinSiWei(String pk_org, String hvnote) { + if (MMValueCheck.isEmpty(pk_org)) { + return false; + } + + try { + // ѯ֯ + String sql = "SELECT code FROM org_orgs WHERE pk_org = ?"; + SQLParameter param = new SQLParameter(); + param.addParam(pk_org); + String orgCode = (String) DAO.executeQuery(sql, param, new ColumnProcessor()); + + // ж֯ǷΪC034 + boolean isCableOrg = "C034".equals(orgCode); + + // жϱעǷ"˼ά" + boolean containsJinSiWei = MMValueCheck.isNotEmpty(hvnote) && hvnote.contains("˼ά"); + + return isCableOrg && containsJinSiWei; + } catch (Exception e) { + // ѯ쳣ʱfalse + return false; + } + } + + /** + * BOM汾 + * @param pk_org ֯ + * @param hcmaterialid ϱ + * @return İ汾 + */ + private String calculateBomVersion(String pk_org, String hcmaterialid ) throws BusinessException { + try { + // ѯ + StringBuilder sql = new StringBuilder(); + sql.append("SELECT MAX(TO_NUMBER(hversion)) as max_version "); + sql.append("FROM bd_bom "); + sql.append("WHERE pk_org = ? "); + + SQLParameter param = new SQLParameter(); + param.addParam(pk_org); + + // Ӳѯ + sql.append("AND hcmaterialid = ? "); + param.addParam(hcmaterialid); + + // ֻѯְ汾ţųְ汾 + sql.append("AND REGEXP_LIKE(hversion, '^[0-9]+$') "); + + Long maxVersion = (Long) DAO.executeQuery(sql.toString(), param, new ColumnProcessor()); + + // ѯݣĬϰ汾Ϊ1汾ż1 + return String.valueOf((maxVersion != null ? maxVersion : 0) + 1); + + } catch (Exception e) { + throw new BusinessException("BOM汾쳣" + e.getMessage()); + } + } }