Compare commits
	
		
			2 Commits
		
	
	
		
			42bed41623
			...
			34b1fbe65d
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						34b1fbe65d | |
| 
							
							
								 | 
						078d370a34 | 
| 
						 | 
				
			
			@ -1,15 +1,17 @@
 | 
			
		|||
package nccloud.api.impl.mmbd.bom;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import nc.bs.dao.BaseDAO;
 | 
			
		||||
import nc.bs.framework.common.InvocationInfoProxy;
 | 
			
		||||
import nc.bs.framework.common.NCLocator;
 | 
			
		||||
import nc.bs.logging.Log;
 | 
			
		||||
import nc.itf.bd.bom.bom0202.IBomBillMaintainService;
 | 
			
		||||
import nc.itf.bd.bom.bom0202.IBomBillQueryService;
 | 
			
		||||
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.md.model.MetaDataException;
 | 
			
		||||
import nc.md.persist.framework.MDPersistenceService;
 | 
			
		||||
import nc.mmbd.utils.factoryparam.MMBDFactoryParameter;
 | 
			
		||||
import nc.pubitf.uapbd.IMaterialPubService;
 | 
			
		||||
import nc.pubitf.uapbd.IMaterialPubService_C;
 | 
			
		||||
| 
						 | 
				
			
			@ -54,9 +56,13 @@ import java.util.stream.Stream;
 | 
			
		|||
public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		||||
 | 
			
		||||
	// 2025年5月28日 电缆组织金思维BOM版本号自动计算处理
 | 
			
		||||
    private static final BaseDAO DAO = new BaseDAO();
 | 
			
		||||
    
 | 
			
		||||
    private static final IHttpPostOtherSys HTTP_POST_OTHER_SYS = NCLocator.getInstance().lookup(IHttpPostOtherSys.class);
 | 
			
		||||
	private static final BaseDAO DAO = new BaseDAO();
 | 
			
		||||
 | 
			
		||||
	private static final IHttpPostOtherSys HTTP_POST_OTHER_SYS = NCLocator.getInstance().lookup(IHttpPostOtherSys.class);
 | 
			
		||||
 | 
			
		||||
	// 2025年7月4日 添加日志支持
 | 
			
		||||
	private static final String LOG_INFO_NAME = "OALOG";
 | 
			
		||||
	private static final Log obmlog = Log.getInstance(LOG_INFO_NAME);
 | 
			
		||||
 | 
			
		||||
	public static final String MESUSERCODE = "MES";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +86,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
	private static Map<String, Object> tsMap = new HashMap();
 | 
			
		||||
 | 
			
		||||
	private String orgCodeFlag =null;
 | 
			
		||||
	private String orgCodeFlag = null;
 | 
			
		||||
 | 
			
		||||
	private static Map<String, Object> voMap = new HashMap();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -106,21 +112,21 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
				list.add(agg);
 | 
			
		||||
			}
 | 
			
		||||
			AggBomVO[] aggVOs = (AggBomVO[]) list.toArray(new AggBomVO[list.size()]);
 | 
			
		||||
			if(aggVOs[0].getParentVO().getAttributeValue("pk_org")==null||aggVOs[0].getParentVO().getAttributeValue("pk_org")==""){
 | 
			
		||||
			if (aggVOs[0].getParentVO().getAttributeValue("pk_org") == null || aggVOs[0].getParentVO().getAttributeValue("pk_org") == "") {
 | 
			
		||||
				ExceptionUtils.wrappBusinessException("请求参数pk_org为空,请检查!!!!");
 | 
			
		||||
			}else{
 | 
			
		||||
				this.orgCodeFlag=aggVOs[0].getParentVO().getAttributeValue("pk_org").toString();
 | 
			
		||||
			} else {
 | 
			
		||||
				this.orgCodeFlag = aggVOs[0].getParentVO().getAttributeValue("pk_org").toString();
 | 
			
		||||
			}
 | 
			
		||||
			BillFieldsCodeToPkUtil.doTranslateVOFields(aggVOs);
 | 
			
		||||
			IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class);
 | 
			
		||||
			for (AggBomVO aggtwo : aggVOs) {
 | 
			
		||||
				BomItemVO[] items = aggtwo.getChildrenVO();
 | 
			
		||||
				//2025年5月9日08点56分--添加表头物料翻译校验	start
 | 
			
		||||
				if(aggtwo.getParent().getAttributeValue("hcmaterialid")!=null){
 | 
			
		||||
				if (aggtwo.getParent().getAttributeValue("hcmaterialid") != null) {
 | 
			
		||||
					MaterialVO headMaterialVO = (MaterialVO) iUifService.queryByPrimaryKey(MaterialVO.class,
 | 
			
		||||
							aggtwo.getParent().getAttributeValue("hcmaterialid").toString());
 | 
			
		||||
					if(headMaterialVO==null){
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【"+aggtwo.getParent().getAttributeValue("hcmaterialid").toString()+"】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					if (headMaterialVO == null) {
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【" + aggtwo.getParent().getAttributeValue("hcmaterialid").toString() + "】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				//2025年5月9日08点56分--添加表头物料翻译校验 end
 | 
			
		||||
| 
						 | 
				
			
			@ -128,8 +134,8 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
					MaterialVO bankAccSub = (MaterialVO) iUifService.queryByPrimaryKey(MaterialVO.class,
 | 
			
		||||
							items[i].getAttributeValue("cmaterialid").toString());
 | 
			
		||||
					//2025年5月7日08点41分 添加为空校验 sdlizheng --start
 | 
			
		||||
					if(bankAccSub==null){
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【"+items[i].getAttributeValue("cmaterialid").toString()+"】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					if (bankAccSub == null) {
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【" + items[i].getAttributeValue("cmaterialid").toString() + "】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					}
 | 
			
		||||
					//2025年5月7日08点41分 添加为空校验 sdlizheng --end
 | 
			
		||||
					items[i].setAttributeValue("cmaterialvid", bankAccSub.getAttributeValue("pk_source"));
 | 
			
		||||
| 
						 | 
				
			
			@ -172,16 +178,17 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
				result = service.insertBom((AggBomVO[]) addAggvoList.toArray(new AggBomVO[0]));
 | 
			
		||||
			} else if (!commitAggvoList.isEmpty() && addAggvoList.isEmpty()) {
 | 
			
		||||
				List<AggBomVO> newAggVOList = new ArrayList<>();
 | 
			
		||||
				if ("gaoning".equals(userCode)|| "C029".equals(orgCodeFlag)) {
 | 
			
		||||
				if ("gaoning".equals(userCode) || "C029".equals(orgCodeFlag)) {
 | 
			
		||||
					for (AggBomVO aggvo : commitAggvoList) {
 | 
			
		||||
						result = service.insertCommitBomWithParam(new AggBomVO[] { aggvo }, true, true);
 | 
			
		||||
						result = service.insertCommitBomWithParam(new AggBomVO[]{aggvo}, true, true);
 | 
			
		||||
//                        insertBomMatchRt(result);
 | 
			
		||||
						newAggVOList.add(result[0]);
 | 
			
		||||
					}
 | 
			
		||||
					return ResultMessageUtil.toJSON(newAggVOList.toArray(new AggBomVO[0]), "BOM保存成功");
 | 
			
		||||
				} else if ("dlkgsrm".equals(userCode)) {
 | 
			
		||||
				} else if ("dlkgsrm".equals(userCode) || "hgqwms".equals(userCode)) {
 | 
			
		||||
					for (AggBomVO aggvo : commitAggvoList) {
 | 
			
		||||
						try {
 | 
			
		||||
							result = service.insertCommitBomWithParam_RequiresNew(new AggBomVO[] { aggvo }, true, true);
 | 
			
		||||
							result = service.insertCommitBomWithParam_RequiresNew(new AggBomVO[]{aggvo}, true, true);
 | 
			
		||||
							newAggVOList.add(result[0]);
 | 
			
		||||
						} catch (Exception e) {
 | 
			
		||||
							if (e.getMessage() != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -204,25 +211,25 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
				} else {
 | 
			
		||||
					try {
 | 
			
		||||
						IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class);
 | 
			
		||||
						
 | 
			
		||||
 | 
			
		||||
						// 检查当前用户是否为排除用户
 | 
			
		||||
						if (httpPostOtherSys.checkIfExcludeUser()) {
 | 
			
		||||
							// 排除用户直接跳过同步处理,执行普通保存逻辑
 | 
			
		||||
							for (AggBomVO aggvo : commitAggvoList) {
 | 
			
		||||
								result = service.insertBom(new AggBomVO[] { aggvo });
 | 
			
		||||
								result = service.insertBom(new AggBomVO[]{aggvo});
 | 
			
		||||
								newAggVOList.add(result[0]);
 | 
			
		||||
							}
 | 
			
		||||
							return ResultMessageUtil.toJSON(newAggVOList.toArray(new AggBomVO[0]), "BOM保存成功(排除用户)");
 | 
			
		||||
						}
 | 
			
		||||
						
 | 
			
		||||
 | 
			
		||||
						// 检查当前组织是否属于金思维MES同步组织(电缆组织)
 | 
			
		||||
						String currentOrgCode = this.orgCodeFlag;
 | 
			
		||||
						boolean isIncludeOrg = httpPostOtherSys.checkIfIncludeOrg(currentOrgCode);
 | 
			
		||||
						
 | 
			
		||||
 | 
			
		||||
						if (isIncludeOrg) {
 | 
			
		||||
							// 属于金思维MES同步组织,执行特殊处理逻辑
 | 
			
		||||
							for (AggBomVO aggvo : commitAggvoList) {
 | 
			
		||||
								result = service.insertCommitBomWithParam(new AggBomVO[] { aggvo }, true, true);
 | 
			
		||||
								result = service.insertCommitBomWithParam(new AggBomVO[]{aggvo}, true, true);
 | 
			
		||||
								newAggVOList.add(result[0]);
 | 
			
		||||
							}
 | 
			
		||||
							return ResultMessageUtil.toJSON(newAggVOList.toArray(new AggBomVO[0]), "BOM保存成功(金思维MES同步组织)");
 | 
			
		||||
| 
						 | 
				
			
			@ -230,7 +237,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
							// 不属于金思维MES同步组织,执行默认处理逻辑
 | 
			
		||||
							for (AggBomVO aggvo : commitAggvoList) {
 | 
			
		||||
								try {
 | 
			
		||||
									result = service.insertCommitBomWithParam_RequiresNew(new AggBomVO[] { aggvo }, true, true);
 | 
			
		||||
									result = service.insertCommitBomWithParam_RequiresNew(new AggBomVO[]{aggvo}, true, true);
 | 
			
		||||
									newAggVOList.add(result[0]);
 | 
			
		||||
								} catch (Exception e) {
 | 
			
		||||
									if (e.getMessage() != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -252,10 +259,10 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
						}
 | 
			
		||||
					} catch (BusinessException e) {
 | 
			
		||||
						// HTTP工具类调用失败时,回退到原有的异常处理
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("HTTP工具类判断失败:" + e.getMessage() + ",未匹配到符合条件的三方注册用户账号【"+userCode+"】,请检查!!!");
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("HTTP工具类判断失败:" + e.getMessage() + ",未匹配到符合条件的三方注册用户账号【" + userCode + "】,请检查!!!");
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
 | 
			
		||||
			} else {
 | 
			
		||||
				return ResultMessageUtil.exceptionToJSON("BOM保存失败,新增不允许单据状态自由或者空和审批通过同时存在", "999");
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -266,6 +273,41 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
//	private void insertBomMatchRt(AggBomVO[] result) throws BusinessException {
 | 
			
		||||
//		AggBomVO aggBomVO = result[0];
 | 
			
		||||
//		BomVO bomVO = (BomVO) aggBomVO.getParentVO();
 | 
			
		||||
//		BomItemVO[] bomItemVOs = aggBomVO.getChildrenVO();
 | 
			
		||||
//		SuperVOUtil.sortByAttributeName(bomItemVOs,"cbeginperiod",false);
 | 
			
		||||
//
 | 
			
		||||
//		BomMatchRtVO bomMatchRtVO = new BomMatchRtVO();
 | 
			
		||||
//		bomMatchRtVO.setStatus(VOStatus.NEW);
 | 
			
		||||
//		bomMatchRtVO.setDr(0);
 | 
			
		||||
//		bomMatchRtVO.setPk_group(PubEnv.getPk_group());
 | 
			
		||||
//		bomMatchRtVO.setPk_org(bomVO.getPk_org());
 | 
			
		||||
//		bomMatchRtVO.setPk_org_v(bomVO.getPk_org_v());
 | 
			
		||||
//		bomMatchRtVO.setCmaterialid(bomVO.getHcmaterialid());
 | 
			
		||||
//		bomMatchRtVO.setCmaterialvid(bomVO.getHcmaterialvid());
 | 
			
		||||
//
 | 
			
		||||
//		String hversion = bomVO.getHversion();
 | 
			
		||||
//		String whereSql = " project_code ='" + hversion + "' and pk_org='" + bomVO.getPk_org() + "' and nvl(dr,0)=0 ";
 | 
			
		||||
	////		IBean bean = MDManageUtil.getBeanByContainedObject(new AggBomVO());
 | 
			
		||||
	////		String hcprojectid = TranslateUtils.trancelateCodeToID(bean, "hcprojectid", hversion, PubEnv.getPk_group());
 | 
			
		||||
//		List<ProjectHeadVO> projectList = (List<ProjectHeadVO>) new BaseDAO().retrieveByClause(ProjectHeadVO.class,
 | 
			
		||||
//				whereSql);
 | 
			
		||||
//		if (projectList != null && projectList.size() > 0) {
 | 
			
		||||
//			bomMatchRtVO.setCprojectid(projectList.get(0).getPk_project());
 | 
			
		||||
//		}
 | 
			
		||||
//
 | 
			
		||||
//		bomMatchRtVO.setDeffectdate(bomItemVOs[0].getCbeginperiod());
 | 
			
		||||
//		bomMatchRtVO.setDloseeffectdate(bomItemVOs[0].getCendperiod());
 | 
			
		||||
//		bomMatchRtVO.setProduction(UFBoolean.TRUE);
 | 
			
		||||
//		bomMatchRtVO.setEntrust(UFBoolean.FALSE);
 | 
			
		||||
//		bomMatchRtVO.setCbomid(bomVO.getPrimaryKey());
 | 
			
		||||
//		IBmrtMaintain iBmrtMaintain = NCLocator.getInstance().lookup(IBmrtMaintain.class);
 | 
			
		||||
//		BomMatchRtVO[] insert = iBmrtMaintain.insert(new BomMatchRtVO[]{bomMatchRtVO});
 | 
			
		||||
//		System.out.println(insert);
 | 
			
		||||
//	}
 | 
			
		||||
	private void dealWithMaterial(AggBomVO agg) {
 | 
			
		||||
		String hcmaterialvid = (String) agg.getParentVO().getAttributeValue("hcmaterialvid");
 | 
			
		||||
		String hcmaterialid = (String) agg.getParentVO().getAttributeValue("hcmaterialid");
 | 
			
		||||
| 
						 | 
				
			
			@ -331,11 +373,11 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
			IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class);
 | 
			
		||||
			for (AggBomVO aggtwo : aggVOs) {
 | 
			
		||||
				//2025年5月9日08点56分--添加表头物料翻译校验	start
 | 
			
		||||
				if(aggtwo.getParent().getAttributeValue("hcmaterialid")!=null){
 | 
			
		||||
				if (aggtwo.getParent().getAttributeValue("hcmaterialid") != null) {
 | 
			
		||||
					MaterialVO headMaterialVO = (MaterialVO) iUifService.queryByPrimaryKey(MaterialVO.class,
 | 
			
		||||
							aggtwo.getParent().getAttributeValue("hcmaterialid").toString());
 | 
			
		||||
					if(headMaterialVO==null){
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【"+aggtwo.getParent().getAttributeValue("hcmaterialid").toString()+"】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					if (headMaterialVO == null) {
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【" + aggtwo.getParent().getAttributeValue("hcmaterialid").toString() + "】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				//2025年5月9日08点56分--添加表头物料翻译校验 end
 | 
			
		||||
| 
						 | 
				
			
			@ -344,8 +386,8 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
					MaterialVO bankAccSub = (MaterialVO) iUifService.queryByPrimaryKey(MaterialVO.class,
 | 
			
		||||
							items[i].getAttributeValue("cmaterialid").toString());
 | 
			
		||||
					//2025年5月7日08点41分 添加为空校验 sdlizheng --start
 | 
			
		||||
					if(bankAccSub==null){
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【"+items[i].getAttributeValue("cmaterialid").toString()+"】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					if (bankAccSub == null) {
 | 
			
		||||
						ExceptionUtils.wrappBusinessException("根据物料【" + items[i].getAttributeValue("cmaterialid").toString() + "】查询物料失败,请在BIP里确认是否物料已存在!!!");
 | 
			
		||||
					}
 | 
			
		||||
					//2025年5月7日08点41分 添加为空校验 sdlizheng --end
 | 
			
		||||
					items[i].setAttributeValue("cmaterialvid", bankAccSub.getAttributeValue("pk_source"));
 | 
			
		||||
| 
						 | 
				
			
			@ -788,7 +830,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
						if (VersionTypeEnum.AVAILABLE.equalsValue(head.getHfversiontype())
 | 
			
		||||
								&& !head.getCbomid().equals(headvo.getCbomid())) {
 | 
			
		||||
							// sdlizheng --添加独立判断--plm三方越过此校验
 | 
			
		||||
							if ("gaoning".equals(userCode) || "dlkgsrm".equals(userCode)|| "C029".equals(this.orgCodeFlag)) {
 | 
			
		||||
							if ("gaoning".equals(userCode) || "dlkgsrm".equals(userCode) || "C029".equals(this.orgCodeFlag) || "hgqwms".equals(userCode)) {
 | 
			
		||||
//								AggBomVO afterVO = service.canceldefault(aggBomVO);
 | 
			
		||||
							} else if (MESUSERCODE.equals(userCode)) {
 | 
			
		||||
								//2025-6-20 添加MES用户判断
 | 
			
		||||
| 
						 | 
				
			
			@ -812,7 +854,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		return (IBomBillQueryService) NCLocator.getInstance().lookup(IBomBillQueryService.class);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void dataSupplement(AggBomVO agg, String userCode) {
 | 
			
		||||
	private void dataSupplement(AggBomVO agg, String userCode) throws BusinessException {
 | 
			
		||||
		orgSupplement(agg, userCode);
 | 
			
		||||
 | 
			
		||||
		// 2025年6月20日 - 处理MES用户的hbdefault(默认)字段设置
 | 
			
		||||
| 
						 | 
				
			
			@ -847,14 +889,14 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
			agg.getParent().setAttributeValue("fbillstatus", Integer.valueOf(-1));
 | 
			
		||||
			agg.getParent().setAttributeValue("hfbomsource", Integer.valueOf(1));
 | 
			
		||||
			agg.getParent().setAttributeValue("hfbomcategory", Integer.valueOf(1));
 | 
			
		||||
			if ("gaoning".equals(userCode) || "dlkgsrm".equals(userCode)|| "C029".equals(this.orgCodeFlag)) {
 | 
			
		||||
			if ("gaoning".equals(userCode) || "dlkgsrm".equals(userCode) || "C029".equals(this.orgCodeFlag) || "hgqwms".equals(userCode)) {
 | 
			
		||||
				// sdlizheng
 | 
			
		||||
				// 1、对于之前不存在的BOM,新增时:如果是传自由态,不默认且无效,走标准逻辑,如果传的是审批态默认且有效。2025年4月11日16点28分 start
 | 
			
		||||
				if (fbillstatus != null && "1".equals(fbillstatus.toString())) {
 | 
			
		||||
					agg.getParent().setAttributeValue("hfversiontype", Integer.valueOf(1));
 | 
			
		||||
					agg.getParent().setAttributeValue("hbdefault", UFBoolean.TRUE);
 | 
			
		||||
				}else if(fbillstatus != null && "-1".equals(fbillstatus.toString())){
 | 
			
		||||
					if("gaoning".equals(userCode)|| "C029".equals(this.orgCodeFlag)){
 | 
			
		||||
				} else if (fbillstatus != null && "-1".equals(fbillstatus.toString())) {
 | 
			
		||||
					if ("gaoning".equals(userCode) || "C029".equals(this.orgCodeFlag)) {
 | 
			
		||||
						agg.getParent().setAttributeValue("hfversiontype", Integer.valueOf(1));
 | 
			
		||||
						agg.getParent().setAttributeValue("hbdefault", UFBoolean.TRUE);
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -979,7 +1021,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		return relation;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void itemSupplement(AggBomVO agg) {
 | 
			
		||||
	private void itemSupplement(AggBomVO agg) throws BusinessException {
 | 
			
		||||
		String pk_org = (String) agg.getParent().getAttributeValue("pk_org");
 | 
			
		||||
		BomItemVO[] items = agg.getChildrenVO();
 | 
			
		||||
		for (BomItemVO item : items) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1027,6 +1069,13 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		handleEvent(items);
 | 
			
		||||
//
 | 
			
		||||
//        IHttpPostOtherSys mesUtils = NCLocator.getInstance().lookup(IHttpPostOtherSys.class);
 | 
			
		||||
//
 | 
			
		||||
//        String code = mesUtils.transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pk_org);
 | 
			
		||||
//        if(mesUtils.checkIfIncludeOrg(code)) {
 | 
			
		||||
//            this.handleEventTwo(agg);
 | 
			
		||||
//        }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void replMaterialOidFill(BomReplVO replVO) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1053,11 +1102,11 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
				hcmaterialvid = ((MaterialVersionVO) ((IMaterialPubService_C) NCLocator.getInstance()
 | 
			
		||||
						.lookup(IMaterialPubService_C.class))
 | 
			
		||||
						.queryMaterialBaseInfoByOidPks(new String[] { hcmaterialoid }, new String[] { "pk_material" })
 | 
			
		||||
						.queryMaterialBaseInfoByOidPks(new String[]{hcmaterialoid}, new String[]{"pk_material"})
 | 
			
		||||
						.get(hcmaterialoid)).toString();
 | 
			
		||||
			}
 | 
			
		||||
			Map<String, MaterialPlanVO> map = queryMaterialPlanInfoByPks(new String[] { hcmaterialvid }, pkorg,
 | 
			
		||||
					new String[] { "fixedahead" });
 | 
			
		||||
			Map<String, MaterialPlanVO> map = queryMaterialPlanInfoByPks(new String[]{hcmaterialvid}, pkorg,
 | 
			
		||||
					new String[]{"fixedahead"});
 | 
			
		||||
 | 
			
		||||
			UFDouble fixedahead = UFDouble.ZERO_DBL;
 | 
			
		||||
			if (MMValueCheck.isNotEmpty(map) && MMValueCheck.isNotEmpty((SuperVO) map.get(hcmaterialvid))
 | 
			
		||||
| 
						 | 
				
			
			@ -1075,7 +1124,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public static Map<String, MaterialPlanVO> queryMaterialPlanInfoByPks(String[] pks, String pk_stockorg,
 | 
			
		||||
			String[] fields) throws BusinessException {
 | 
			
		||||
																		 String[] fields) throws BusinessException {
 | 
			
		||||
		Map<String, MaterialPlanVO> map = null;
 | 
			
		||||
 | 
			
		||||
		List<String> vids = (List) Stream.of(pks).filter(e -> (e != null)).distinct().collect(Collectors.toList());
 | 
			
		||||
| 
						 | 
				
			
			@ -1305,7 +1354,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		return (BomLossVO[]) list.toArray(new BomLossVO[0]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public BomItemVO[] handleEvent(BomItemVO[] items) {
 | 
			
		||||
	public BomItemVO[] handleEvent(BomItemVO[] items) throws BusinessException {
 | 
			
		||||
		List<String> itemCmaterialvids = new ArrayList<String>();
 | 
			
		||||
		for (BomItemVO item : items) {
 | 
			
		||||
			if (MMValueCheck.isNotEmpty(item.getCmaterialvid())) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1385,6 +1434,36 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		return items;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public BomItemVO[] handleEventTwo( AggBomVO agg) throws MetaDataException {
 | 
			
		||||
		IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class);
 | 
			
		||||
		BomItemVO[] items = agg.getChildrenVO();
 | 
			
		||||
		for(BomItemVO item : items) {
 | 
			
		||||
			StringBuffer whereSqlitem = new StringBuffer();
 | 
			
		||||
			whereSqlitem.append(" hcmaterialid = '"+item.getCmaterialid()+"'").append(" and dr ='0'");
 | 
			
		||||
			Collection<AggBomVO> aggBomVOitem;
 | 
			
		||||
			try {
 | 
			
		||||
				aggBomVOitem = MDPersistenceService.lookupPersistenceQueryService().queryBillOfVOByCond(AggBomVO.class, whereSqlitem.toString(), false);
 | 
			
		||||
				if(Objects.nonNull(aggBomVOitem)&&!aggBomVOitem.isEmpty() ) {
 | 
			
		||||
					StringBuffer whereSql = new StringBuffer();
 | 
			
		||||
					whereSql.append(" hcmaterialid =  '"+item.getCmaterialid()+"'").append(" and hvdef3 ='"+agg.getParent().getAttributeValue("hvdef3")+"'").append(" and hvdef2 ='"+agg.getParent().getAttributeValue("hvdef2")+"'").append(" and dr ='0'");
 | 
			
		||||
					Collection<AggBomVO> aggBomVO;
 | 
			
		||||
					aggBomVO = MDPersistenceService.lookupPersistenceQueryService().queryBillOfVOByCond(AggBomVO.class, whereSql.toString(), false);
 | 
			
		||||
					if(Objects.nonNull(aggBomVO) && aggBomVO.size()==1) {
 | 
			
		||||
						for (AggBomVO aggBom : aggBomVO) {
 | 
			
		||||
							item.setVitemversion(aggBom.getPrimaryKey());
 | 
			
		||||
						}
 | 
			
		||||
					}else {
 | 
			
		||||
						nccloud.base.exception.ExceptionUtils.wrapBusinessException("根据条件未查出bom或者查出多条bom不唯一"+whereSql);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			} catch (MetaDataException e1) {
 | 
			
		||||
				e1.printStackTrace();
 | 
			
		||||
				ExceptionUtils.wrappBusinessException(e1.toString());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return items;
 | 
			
		||||
	}
 | 
			
		||||
	void setMaterialInfo(Map<String, BomMaterialParam> materialMap, BomItemVO item) {
 | 
			
		||||
		String materialvid = item.getCmaterialvid();
 | 
			
		||||
		if (!materialMap.containsKey(materialvid)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1456,11 +1535,11 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		for (BomOutputsVO item : items) {
 | 
			
		||||
			try {
 | 
			
		||||
				materialMap = ((IBomBillQueryService) NCLocator.getInstance().lookup(IBomBillQueryService.class))
 | 
			
		||||
						.queryMaterialInfo(item.getPk_org(), new String[] { item.getCmaterialvid() });
 | 
			
		||||
						.queryMaterialInfo(item.getPk_org(), new String[]{item.getCmaterialvid()});
 | 
			
		||||
 | 
			
		||||
				Map<String, MeasureVO> measurevoMap = new HashMap<String, MeasureVO>();
 | 
			
		||||
				IMeasesureService service = (IMeasesureService) NCLocator.getInstance().lookup(IMeasesureService.class);
 | 
			
		||||
				measurevoMap.putAll(service.getMeasureInfoMap(new String[] { item.getCmaterialvid() }));
 | 
			
		||||
				measurevoMap.putAll(service.getMeasureInfoMap(new String[]{item.getCmaterialvid()}));
 | 
			
		||||
				if (measurevoMap.containsKey(item.getCmaterialvid())) {
 | 
			
		||||
					item.setVchangerate(((MeasureVO) measurevoMap.get(item.getCmaterialvid())).getVchangeRate());
 | 
			
		||||
					item.setCastunitid(((MeasureVO) measurevoMap.get(item.getCmaterialvid())).getCassMeasures());
 | 
			
		||||
| 
						 | 
				
			
			@ -1533,7 +1612,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
					|| MMValueCheck.isEmpty(fsupplymode) || MMValueCheck.isEmpty(fcontrol)
 | 
			
		||||
					|| MMValueCheck.isEmpty(cbeginperiod) || MMValueCheck.isEmpty(cendperiod)
 | 
			
		||||
					|| MMValueCheck.isEmpty(fbackflushtype)) {
 | 
			
		||||
				return ResultMessageUtil.exceptionToJSON("传入数据异常,子表材料第" + i + 1 + "行存在未填的必输项", "1");
 | 
			
		||||
				return ResultMessageUtil.exceptionToJSON("传入数据异常,子表材料第" + i + 1 + "行"+ cmaterialvid +"存在未填的必输项", "1");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1547,7 +1626,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
			String cmaterialvid = outputsVO.getCmaterialvid();
 | 
			
		||||
 | 
			
		||||
			if (MMValueCheck.isEmpty(foutputtype) || MMValueCheck.isEmpty(cmaterialvid)) {
 | 
			
		||||
				return ResultMessageUtil.exceptionToJSON("传入数据异常,联副产品第" + j + 1 + "行存在未填的必输项", "1");
 | 
			
		||||
				return ResultMessageUtil.exceptionToJSON("传入数据异常,联副产品第" + j + 1 + "行"+cmaterialvid+"存在未填的必输项", "1");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1558,8 +1637,8 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
		Map<String, MaterialVO> materialSourceMap = new HashMap<String, MaterialVO>();
 | 
			
		||||
		try {
 | 
			
		||||
			materialSourceMap = ((IMaterialPubService_C) NCLocator.getInstance().lookup(IMaterialPubService_C.class))
 | 
			
		||||
					.queryMaterialBaseInfoByPks(new String[] { materialVid },
 | 
			
		||||
							new String[] { "pk_source", "graphid", "materialspec", "materialtype" });
 | 
			
		||||
					.queryMaterialBaseInfoByPks(new String[]{materialVid},
 | 
			
		||||
							new String[]{"pk_source", "graphid", "materialspec", "materialtype"});
 | 
			
		||||
 | 
			
		||||
		} catch (BusinessException e1) {
 | 
			
		||||
			ResultMessageUtil.exceptionToJSON(e1);
 | 
			
		||||
| 
						 | 
				
			
			@ -1590,7 +1669,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
			String hvnote = (String) agg.getParent().getAttributeValue("hvnote");
 | 
			
		||||
 | 
			
		||||
			// 检查必要字段
 | 
			
		||||
			if (MMValueCheck.isEmpty(hcmaterialid)  || MMValueCheck.isEmpty(hversion)) {
 | 
			
		||||
			if (MMValueCheck.isEmpty(hcmaterialid) || MMValueCheck.isEmpty(hversion)) {
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1599,7 +1678,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
			if (isCableOrgJinSiWei) {
 | 
			
		||||
				// 计算版本号
 | 
			
		||||
				String calculatedVersion = calculateBomVersion(pk_org, hcmaterialid );
 | 
			
		||||
				String calculatedVersion = calculateBomVersion(pk_org, hcmaterialid);
 | 
			
		||||
				agg.getParent().setAttributeValue("hversion", calculatedVersion);
 | 
			
		||||
			}
 | 
			
		||||
		} catch (Exception e) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1609,6 +1688,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 判断是否为电缆组织且备注包含金思维
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param pk_org 组织主键
 | 
			
		||||
	 * @param hvnote 备注信息
 | 
			
		||||
	 * @return 是否符合条件
 | 
			
		||||
| 
						 | 
				
			
			@ -1640,33 +1720,34 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 计算BOM版本号
 | 
			
		||||
	 * @param pk_org 组织主键
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param pk_org       组织主键
 | 
			
		||||
	 * @param hcmaterialid 物料编码
 | 
			
		||||
	 * @return 计算出的版本号
 | 
			
		||||
	 */
 | 
			
		||||
	private String calculateBomVersion(String pk_org, String hcmaterialid ) throws BusinessException {
 | 
			
		||||
	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("SELECT MAX(TO_NUMBER(hversion)) as max_version ");
 | 
			
		||||
			sql.append("FROM bd_bom ");
 | 
			
		||||
			sql.append("WHERE dr = 0 and pk_org = ? ");
 | 
			
		||||
 | 
			
		||||
			SQLParameter param = new SQLParameter();
 | 
			
		||||
			param.addParam(pk_org);
 | 
			
		||||
 | 
			
		||||
			// 根据物料情况添加查询条件
 | 
			
		||||
            sql.append("AND hcmaterialid = ? ");
 | 
			
		||||
            param.addParam(hcmaterialid);
 | 
			
		||||
			sql.append("AND hcmaterialid = ? ");
 | 
			
		||||
			param.addParam(hcmaterialid);
 | 
			
		||||
 | 
			
		||||
            // 只查询数字版本号,排除非数字版本
 | 
			
		||||
            sql.append("AND REGEXP_LIKE(hversion, '^[0-9]+$') ");
 | 
			
		||||
            // 如果查询不到数据,默认版本号为1;否则最大版本号加1
 | 
			
		||||
            Object mayBeNullVersion = DAO.executeQuery(sql.toString(), param, new ColumnProcessor());
 | 
			
		||||
            String number = Objects.isNull(mayBeNullVersion) ? "1" : DAO.executeQuery(sql.toString(), param, new ColumnProcessor()).toString();
 | 
			
		||||
            return String.valueOf(Long.parseLong(number)+1);
 | 
			
		||||
			// 只查询数字版本号,排除非数字版本
 | 
			
		||||
			sql.append("AND REGEXP_LIKE(hversion, '^[0-9]+$') ");
 | 
			
		||||
			// 如果查询不到数据,默认版本号为1;否则最大版本号加1
 | 
			
		||||
			Object mayBeNullVersion = DAO.executeQuery(sql.toString(), param, new ColumnProcessor());
 | 
			
		||||
			String number = Objects.isNull(mayBeNullVersion) ? "1" : DAO.executeQuery(sql.toString(), param, new ColumnProcessor()).toString();
 | 
			
		||||
			return String.valueOf(Long.parseLong(number) + 1);
 | 
			
		||||
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
		} catch (Exception e) {
 | 
			
		||||
			throw new BusinessException("计算BOM版本号异常:" + e.getMessage());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1674,28 +1755,44 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
	/**
 | 
			
		||||
	 * 处理MES用户的hbdefault字段设置逻辑
 | 
			
		||||
	 * 2025年6月20日新增 - 专门用于MES用户的处理
 | 
			
		||||
	 * 仿照orgSupplement方法编写
 | 
			
		||||
	 * 2025年7月10日修改 - 改为根据自定义项hvdef4判断是否为定制BOM
 | 
			
		||||
	 * 同步MES时:只有标准版本的bom "默认"(hbdefault) 生效(hfversiontype的等于1)
 | 
			
		||||
	 * 定制bom(hvdef4值为Y)取消 "默认"(hbdefault,值为N) 但生效(hfversiontype的等于1)
 | 
			
		||||
	 * @auther 毛磊
 | 
			
		||||
	 * @param agg AggBomVO对象
 | 
			
		||||
	 * @param userCode 用户代码
 | 
			
		||||
	 */
 | 
			
		||||
	private void handleMesUserDefaultSetting(AggBomVO agg, String userCode) {
 | 
			
		||||
		obmlog.debug("handleMesUserDefaultSetting - 开始处理MES用户的默认设置逻辑,用户代码:" + userCode);
 | 
			
		||||
 | 
			
		||||
		// 仅针对MES用户进行处理
 | 
			
		||||
		if (!MESUSERCODE.equals(userCode)) {
 | 
			
		||||
			obmlog.debug("handleMesUserDefaultSetting - 非MES用户,跳过处理");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		Object fbillstatus = agg.getParent().getAttributeValue("fbillstatus");
 | 
			
		||||
		
 | 
			
		||||
		// MES用户新增时,按照与gaoning和dlkgsrm相同的逻辑处理hbdefault字段
 | 
			
		||||
		if (fbillstatus != null && "1".equals(fbillstatus.toString())) {
 | 
			
		||||
			// 审批态时:设置为默认且有效
 | 
			
		||||
			agg.getParent().setAttributeValue("hfversiontype", Integer.valueOf(1));
 | 
			
		||||
			agg.getParent().setAttributeValue("hbdefault", UFBoolean.TRUE);
 | 
			
		||||
		} else if (fbillstatus != null && "-1".equals(fbillstatus.toString())) {
 | 
			
		||||
			// 自由态时:设置为默认且有效(与gaoning用户逻辑一致)
 | 
			
		||||
			agg.getParent().setAttributeValue("hfversiontype", Integer.valueOf(1));
 | 
			
		||||
			agg.getParent().setAttributeValue("hbdefault", UFBoolean.TRUE);
 | 
			
		||||
		// 获取自定义项hvdef4的值
 | 
			
		||||
		String hvdef4 = (String) agg.getParent().getAttributeValue("hvdef4");
 | 
			
		||||
		obmlog.debug("handleMesUserDefaultSetting - 获取到自定义项hvdef4的值:" + hvdef4);
 | 
			
		||||
 | 
			
		||||
		// 判断是否为定制BOM(hvdef4值为Y时为定制BOM,其余情况为标准版本)
 | 
			
		||||
		boolean isCustomBom = "Y".equals(hvdef4);
 | 
			
		||||
		obmlog.debug("handleMesUserDefaultSetting - 是否为定制BOM:" + isCustomBom);
 | 
			
		||||
 | 
			
		||||
		// 所有MES用户的BOM都设置为生效状态
 | 
			
		||||
		agg.getParent().setAttributeValue("hfversiontype", 1);
 | 
			
		||||
		obmlog.debug("handleMesUserDefaultSetting - 设置版本类型为生效状态(hfversiontype=1)");
 | 
			
		||||
 | 
			
		||||
		if (isCustomBom) {
 | 
			
		||||
			// 定制BOM:取消默认但仍然生效
 | 
			
		||||
			agg.getParent().setAttributeValue("hbdefault","N");
 | 
			
		||||
			obmlog.debug("handleMesUserDefaultSetting - 定制BOM,取消默认(hbdefault=false)");
 | 
			
		||||
		} else {
 | 
			
		||||
			// 标准版本:设置为默认且生效
 | 
			
		||||
			agg.getParent().setAttributeValue("hbdefault", "Y");
 | 
			
		||||
			obmlog.debug("handleMesUserDefaultSetting - 标准版本,设置为默认(hbdefault=true)");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		obmlog.debug("handleMesUserDefaultSetting - MES用户默认设置处理完成");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue