uapbd: BOM新增时,电缆组织金思维BOM版本号自动计算
- 新增处理电缆组织金思维BOM版本号的方法 - 判断是否为电缆组织且备注包含金思维 - 计算BOM版本号并更新到BOM主表
This commit is contained in:
parent
1b8e919b42
commit
508996fb3d
|
@ -1,21 +1,15 @@
|
||||||
package nccloud.api.impl.mmbd.bom;
|
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.InvocationInfoProxy;
|
||||||
import nc.bs.framework.common.NCLocator;
|
import nc.bs.framework.common.NCLocator;
|
||||||
import nc.itf.bd.bom.bom0202.IBomBillMaintainService;
|
import nc.itf.bd.bom.bom0202.IBomBillMaintainService;
|
||||||
import nc.itf.bd.bom.bom0202.IBomBillQueryService;
|
import nc.itf.bd.bom.bom0202.IBomBillQueryService;
|
||||||
import nc.itf.bd.bom.bom0202.IBomBusinessService;
|
|
||||||
import nc.itf.mmf.busi.measure.IMeasesureService;
|
import nc.itf.mmf.busi.measure.IMeasesureService;
|
||||||
import nc.itf.uif.pub.IUifService;
|
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.mmbd.utils.factoryparam.MMBDFactoryParameter;
|
||||||
import nc.pubitf.uapbd.IMaterialPubService;
|
import nc.pubitf.uapbd.IMaterialPubService;
|
||||||
import nc.pubitf.uapbd.IMaterialPubService_C;
|
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.measure.NumScaleUtil;
|
||||||
import nc.util.mmf.busi.service.OrgUnitPubService;
|
import nc.util.mmf.busi.service.OrgUnitPubService;
|
||||||
import nc.util.mmf.framework.base.MMValueCheck;
|
import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
import nc.vo.bd.bom.bom0202.entity.AggBomVO;
|
import nc.vo.bd.bom.bom0202.entity.*;
|
||||||
import nc.vo.bd.bom.bom0202.entity.BomActivityVO;
|
import nc.vo.bd.bom.bom0202.enumeration.*;
|
||||||
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.paramvo.BomHeadMtrlParam;
|
import nc.vo.bd.bom.bom0202.paramvo.BomHeadMtrlParam;
|
||||||
import nc.vo.bd.bom.bom0202.paramvo.BomHeadMtrlResult;
|
import nc.vo.bd.bom.bom0202.paramvo.BomHeadMtrlResult;
|
||||||
import nc.vo.bd.bom.bom0202.paramvo.BomMaterialParam;
|
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 nccloud.vo.bd.bom.bom0202.validate.BomSavingValidation;
|
||||||
import org.json.JSONString;
|
import org.json.JSONString;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
||||||
|
|
||||||
|
// 2025年5月28日 电缆组织金思维BOM版本号自动计算处理
|
||||||
|
private static final BaseDAO DAO = new BaseDAO();
|
||||||
|
|
||||||
private static String HEADTABLE = "bd_bom";
|
private static String HEADTABLE = "bd_bom";
|
||||||
|
|
||||||
private static String BODYTABLE = "bd_bom_b";
|
private static String BODYTABLE = "bd_bom_b";
|
||||||
|
@ -155,6 +142,10 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
||||||
}
|
}
|
||||||
// zhangxinah ¶ÔÎïÁÏÖ÷¼ü½øÐзÒë
|
// zhangxinah ¶ÔÎïÁÏÖ÷¼ü½øÐзÒë
|
||||||
dealWithMaterial(agg);
|
dealWithMaterial(agg);
|
||||||
|
|
||||||
|
// 2025年5月28日 电缆组织金思维BOM版本号自动计算处理 By maolei
|
||||||
|
handleCableOrgJinSiWeiBomVersion(agg);
|
||||||
|
|
||||||
dataSupplement(agg, userCode);
|
dataSupplement(agg, userCode);
|
||||||
|
|
||||||
UFBoolean flag = (UFBoolean) agg.getParent().getAttributeValue("hbdefault");
|
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"));
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue