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;
 | 
			
		||||
| 
						 | 
				
			
			@ -58,6 +60,10 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
	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";
 | 
			
		||||
 | 
			
		||||
	private static String HEADTABLE = "bd_bom";
 | 
			
		||||
| 
						 | 
				
			
			@ -175,10 +181,11 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
				if ("gaoning".equals(userCode) || "C029".equals(orgCodeFlag)) {
 | 
			
		||||
					for (AggBomVO aggvo : commitAggvoList) {
 | 
			
		||||
						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);
 | 
			
		||||
| 
						 | 
				
			
			@ -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");
 | 
			
		||||
| 
						 | 
				
			
			@ -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,7 +889,7 @@ 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())) {
 | 
			
		||||
| 
						 | 
				
			
			@ -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) {
 | 
			
		||||
| 
						 | 
				
			
			@ -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)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -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");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1609,6 +1688,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 判断是否为电缆组织且备注包含金思维
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param pk_org 组织主键
 | 
			
		||||
	 * @param hvnote 备注信息
 | 
			
		||||
	 * @return 是否符合条件
 | 
			
		||||
| 
						 | 
				
			
			@ -1640,6 +1720,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 计算BOM版本号
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param pk_org       组织主键
 | 
			
		||||
	 * @param hcmaterialid 物料编码
 | 
			
		||||
	 * @return 计算出的版本号
 | 
			
		||||
| 
						 | 
				
			
			@ -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");
 | 
			
		||||
		// 获取自定义项hvdef4的值
 | 
			
		||||
		String hvdef4 = (String) agg.getParent().getAttributeValue("hvdef4");
 | 
			
		||||
		obmlog.debug("handleMesUserDefaultSetting - 获取到自定义项hvdef4的值:" + hvdef4);
 | 
			
		||||
 | 
			
		||||
		// 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);
 | 
			
		||||
		}
 | 
			
		||||
		// 判断是否为定制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