diff --git a/uapbd/src/private/nc/impl/bd/material/baseinfo/MaterialAsstFrame1ChangedListener.java b/uapbd/src/private/nc/impl/bd/material/baseinfo/MaterialAsstFrame1ChangedListener.java new file mode 100644 index 0000000..c07a641 --- /dev/null +++ b/uapbd/src/private/nc/impl/bd/material/baseinfo/MaterialAsstFrame1ChangedListener.java @@ -0,0 +1,673 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nc.impl.bd.material.baseinfo; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import nc.bs.bd.cache.CacheProxy; +import nc.bs.businessevent.IBusinessEvent; +import nc.bs.businessevent.IBusinessListener; +import nc.bs.businessevent.bd.BDCommonEvent; +import nc.bs.businessevent.bd.BDCommonEventUtil; +import nc.bs.dao.BaseDAO; +import nc.bs.dao.DAOException; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.logging.Logger; +import nc.impl.bd.material.prod.MaterialProdAsstFrameChangedListner; +import nc.jdbc.framework.SQLParameter; +import nc.jdbc.framework.processor.ColumnListProcessor; +import nc.md.persist.framework.IMDPersistenceQueryService; +import nc.md.persist.framework.MDPersistenceService; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.material.cost.MaterialCostVO; +import nc.vo.bd.material.cost.MaterialCostmodeVO; +import nc.vo.bd.material.marassistant.MarAssistantVO; +import nc.vo.bd.material.plan.MaterialPlanVO; +import nc.vo.bd.material.prod.MaterialProdVO; +import nc.vo.bd.material.stock.MaterialStockVO; +import nc.vo.pub.BusinessException; +import nc.vo.pub.SuperVO; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.trade.sqlutil.IInSqlBatchCallBack; +import nc.vo.trade.sqlutil.InSqlBatchCaller; +import nc.vo.util.BDPKLockUtil; +import nccloud.commons.lang.ArrayUtils; +import nccloud.commons.lang.StringUtils; + +public class MaterialAsstFrame1ChangedListener implements IBusinessListener { + private BaseDAO baseDAO = new BaseDAO(); + private static final String FIXPRECODE = "fixasst"; + private static final String FREEPRECODE = "freeasst"; + private IMDPersistenceQueryService mdPersistenceQueryService = null; + + + public MaterialAsstFrame1ChangedListener() { + } + + public void doAction(IBusinessEvent e) throws BusinessException { + if (e instanceof BDCommonEvent event) { + if ("c7dc0ccd-8872-4eee-8882-160e8f49dfad".equals(event.getSourceID())) { + if ("1004".equals(event.getEventType()) ) { + this.dealMaterialStockAssts(event, false);//库存信息分配后 + this.dealMaterialPlanUpdateAssts(event, false);//计划信息分配后 +// this.dealMaterialProdUpdateAssts(event, false);//生产信息 +// this.dealMaterialCostAssts(event, false);//成本信息分配后 + + } else if ("1061".equals(event.getEventType())) { + this.dealMaterialStockAssts(event, true); + this.dealMaterialPlanUpdateAssts(event, true); + } +// else if ("1002".equals(event.getEventType())) { +// this.dealMaterialStockAssts1(event, false); +// this.dealMaterialPlanUpdateAssts1(event, false); +// } + }else if("8b7d49ab-7a65-4885-bcf1-7df89b84df4b".equals(event.getSourceID())){ + //计划信息分配后 + if ("1009".equals(event.getEventType()) ) { + this.dealMaterialStockAssts1(event, false); + this.dealMaterialPlanUpdateAssts1(event, false); + } + } + } + + } + + private void dealMaterialStockAssts(BDCommonEvent event, boolean isBatchUp) throws BusinessException { + for(int i = 0; i < event.getOldObjs().length; ++i) { + MaterialVO oldVO = (MaterialVO)event.getOldObjs()[i]; + MaterialVO newVO = (MaterialVO)event.getNewObjs()[i]; + if (!StringUtils.equals(oldVO.getPk_marasstframe(), newVO.getPk_marasstframe())) { + String pk_material = newVO.getPk_material(); + String pk_marasstframe = newVO.getPk_marasstframe(); + if (!isBatchUp) { + BDPKLockUtil.lockString(new String[]{pk_material}); + } + //库存 + this.updateMaterialStockUpdateAssts(pk_marasstframe, pk_material); + //成本 + this.updateMaterialCostUpdateAssts(pk_marasstframe, pk_material); + //生产信息 + this.updateMaterialProdAssts(pk_marasstframe, pk_material); + } + } + + } + + private void dealMaterialStockAssts1(BDCommonEvent event, boolean isBatchUp) throws BusinessException { + for(int i = 0; i < event.getNewObjs().length; ++i) { + MaterialStockVO newVO = (MaterialStockVO)event.getNewObjs()[i]; + String pk_material = newVO.getPk_material(); + String pk_marasstframe = this.getmarasstframe(pk_material).get(0); + if (!isBatchUp) { + BDPKLockUtil.lockString(new String[]{pk_material}); + } + + this.updateMaterialStockUpdateAssts(pk_marasstframe, pk_material); + } + + } + + + private void updateMaterialStockUpdateAssts(String pk_marasstframe, String materialVID) throws BusinessException { + List pks = this.queryToUpdateStockPks(materialVID); + if (!pks.isEmpty()) { + this.updateMaterialStockAsstByPks1(this.getField(pk_marasstframe), pks); + } + } + + private List queryToUpdateStockPks(String materialVID) throws BusinessException { + String sql = "select pk_materialstock from " + MaterialStockVO.getDefaultTableName() + " where pk_material = ? "; + SQLParameter param = new SQLParameter(); + param.addParam(materialVID); + return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor()); + } + private void updateMaterialStockAsstByPks1(Set notAllowFields, List pks) throws BusinessException { + Map pk_stock_map = this.queryToUpdateVOs(pks); + List newVOs = this.getUpdateStockVOs1(notAllowFields, pk_stock_map); + if (!newVOs.isEmpty()) { + MaterialStockVO[] vos = (MaterialStockVO[])newVOs.toArray(new MaterialStockVO[0]); + MaterialStockVO[] oldVOs = this.getOldVOs(vos, pk_stock_map); + BDCommonEventUtil eventUtil = new BDCommonEventUtil("13636fc1-0215-4102-a11e-af4be73a05ab"); + eventUtil.setOldObjs(oldVOs); + eventUtil.dispatchUpdateBeforeEvent((Object[])vos); + this.getBaseDAO().updateVOArray(vos, (String[])notAllowFields.toArray(new String[0])); + CacheProxy.fireDataUpdated(MaterialStockVO.getDefaultTableName()); + eventUtil.dispatchUpdateAfterEvent((Object[])vos); + } + + } + + private Map queryToUpdateVOs(List pks) throws BusinessException { + InSqlBatchCaller caller = new InSqlBatchCaller((String[])pks.toArray(new String[0])); + + try { + return (Map)caller.execute(new IInSqlBatchCallBack() { + Map pk_stock_map = new HashMap(); + + public Object doWithInSql(String inSql) throws BusinessException, SQLException { + Collection col = MaterialAsstFrame1ChangedListener.this.getBaseDAO().retrieveByClause(MaterialStockVO.class, "pk_materialstock in " + inSql); + if (col != null) { + for(MaterialStockVO vo : col) { + this.pk_stock_map.put(vo.getPrimaryKey(), vo); + } + } + + return this.pk_stock_map; + } + }); + } catch (SQLException e) { + Logger.error(e.getMessage(), e); + throw new BusinessException(e.getMessage(), e); + } + } + + private List getUpdateStockVOs1(Set notAllowFields, Map pk_stock_map) { + List newVOs = new ArrayList(); + if (pk_stock_map != null && !pk_stock_map.isEmpty()) { + for(MaterialStockVO oldVO : pk_stock_map.values()) { + boolean valueChanged = false; + MaterialStockVO newVO = (MaterialStockVO)oldVO.clone(); + + for(String field : notAllowFields) { + valueChanged = true; + newVO.setAttributeValue(field, UFBoolean.TRUE); + } + + if (valueChanged) { + newVOs.add(newVO); + } + } + + return newVOs; + } else { + return newVOs; + } + } + + + private MaterialStockVO[] getOldVOs(MaterialStockVO[] vos, Map pk_stock_map) { + MaterialStockVO[] oldVOs = new MaterialStockVO[vos.length]; + + for(int i = 0; i < vos.length; ++i) { + oldVOs[i] = (MaterialStockVO)pk_stock_map.get(vos[i].getPrimaryKey()); + } + + return oldVOs; + } + private Set getField(String pk_marasstframe) throws DAOException { + List codes = this.queryMarasstCodesByFrameID(pk_marasstframe); + Set allowFields = new HashSet(); + //如果项目被更改项目需要被默认选中 + for(int i = 2; i <= 16; ++i) { + if (codes.contains(Integer.toString(i)) ) { + allowFields.add(this.getAsstCodeByIndex(i)); + } + } + + return allowFields; + } + + public String getAsstCodeByIndex(int index) { + if (Integer.parseInt("16") == index) { + return "fixasst100"; + } else { + return index >= 6 && index <= 15 ? "freeasst" + (index - 5) : "fixasst" + index; + } + } + + private List queryMarasstCodesByFrameID(String pk_marasstframe) throws DAOException { + String sql = "select code from " + MarAssistantVO.getDefaultTableName() + " where pk_marasstframe = ?"; + SQLParameter param = new SQLParameter(); + param.addParam(pk_marasstframe); + List codes = (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor()); + return codes; + } + + private BaseDAO getBaseDAO() { + if (this.baseDAO == null) { + this.baseDAO = new BaseDAO(); + } + + return this.baseDAO; + } + + + + + + + + + + + + + + + + + + + + + + + private void dealMaterialPlanUpdateAssts(BDCommonEvent event, boolean isBatchUp) throws BusinessException { + for(int i = 0; i < event.getOldObjs().length; ++i) { + MaterialVO oldVO = (MaterialVO)event.getOldObjs()[i]; + MaterialVO newVO = (MaterialVO)event.getNewObjs()[i]; + if (!StringUtils.equals(oldVO.getPk_marasstframe(), newVO.getPk_marasstframe())) { + String pk_material = newVO.getPk_material(); + String pk_marasstframe = newVO.getPk_marasstframe(); + if (!isBatchUp) { + BDPKLockUtil.lockString(new String[]{pk_material}); + } + + this.updateMaterialPlanAssts(pk_marasstframe, pk_material); + } + } + + } + private void dealMaterialPlanUpdateAssts1(BDCommonEvent event, boolean isBatchUp) throws BusinessException { + for(int i = 0; i < event.getNewObjs().length; ++i) { + MaterialPlanVO newVO = (MaterialPlanVO)event.getNewObjs()[i]; + String pk_material = newVO.getPk_material(); + String pk_marasstframe = this.getmarasstframe(pk_material).get(0); + if (!isBatchUp) { + BDPKLockUtil.lockString(new String[]{pk_material}); + } + + this.updateMaterialPlanAssts(pk_marasstframe, pk_material); + } + + } + + private void updateMaterialPlanAssts(String pk_marasstframe, String materialVID) throws BusinessException { + List pks = this.queryToUpdatePlanPks(materialVID); + if (!pks.isEmpty()) { + this.updateMaterialPlanAsstByPks(this.getField1(pk_marasstframe), pks); + } + } + + private List queryToUpdatePlanPks(String materialVID) throws BusinessException { + String sql = "select pk_materialplan from " + MaterialPlanVO.getDefaultTableName() + " where pk_material = ? "; + SQLParameter param = new SQLParameter(); + param.addParam(materialVID); + return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor()); + } + + private void updateMaterialPlanAsstByPks(Set notAllowFields, List pks) throws BusinessException { + Map pk_plan_map = this.queryToUpdateVOs1(pks); + List newVOs = this.getUpdatePlanVOs2(notAllowFields, pk_plan_map); + if (!newVOs.isEmpty()) { + MaterialPlanVO[] vos = (MaterialPlanVO[])newVOs.toArray(new MaterialPlanVO[0]); + MaterialPlanVO[] oldVOs = this.getOldVOs1(vos, pk_plan_map); + BDCommonEventUtil eventUtil = new BDCommonEventUtil("8b7d49ab-7a65-4885-bcf1-7df89b84df4b"); + eventUtil.setOldObjs(oldVOs); + eventUtil.dispatchUpdateBeforeEvent((Object[])vos); + this.getBaseDAO().updateVOArray(vos, (String[])notAllowFields.toArray(new String[0])); + CacheProxy.fireDataUpdated(MaterialPlanVO.getDefaultTableName()); + eventUtil.dispatchUpdateAfterEvent((Object[])vos); + } + } + private Map queryToUpdateVOs1(List pks) throws BusinessException { + InSqlBatchCaller caller = new InSqlBatchCaller((String[])pks.toArray(new String[0])); + + try { + return (Map)caller.execute(new IInSqlBatchCallBack() { + Map pk_plan_map = new HashMap(); + + public Object doWithInSql(String inSql) throws BusinessException, SQLException { + Collection col = MaterialAsstFrame1ChangedListener.this.getBaseDAO().retrieveByClause(MaterialPlanVO.class, "pk_materialplan in " + inSql); + if (col != null) { + for(MaterialPlanVO vo : col) { + this.pk_plan_map.put(vo.getPrimaryKey(), vo); + } + } + + return this.pk_plan_map; + } + }); + } catch (SQLException e) { + Logger.error(e.getMessage(), e); + throw new BusinessException(e.getMessage(), e); + } + } + private List getUpdatePlanVOs2(Set notAllowFields, Map pk_plan_map) { + List newVOs = new ArrayList(); + if (pk_plan_map != null && !pk_plan_map.isEmpty()) { + for(MaterialPlanVO oldVO : pk_plan_map.values()) { + boolean valueChanged = false; + MaterialPlanVO newVO = (MaterialPlanVO)oldVO.clone(); + + for(String field : notAllowFields) { + valueChanged = true; + newVO.setAttributeValue(field, UFBoolean.TRUE); + } + + if (valueChanged) { + newVOs.add(newVO); + } + } + + return newVOs; + } else { + return newVOs; + } + } + private MaterialPlanVO[] getOldVOs1(MaterialPlanVO[] vos, Map pk_plan_map) { + MaterialPlanVO[] oldVOs = new MaterialPlanVO[vos.length]; + + for(int i = 0; i < vos.length; ++i) { + oldVOs[i] = (MaterialPlanVO)pk_plan_map.get(vos[i].getPrimaryKey()); + } + + return oldVOs; + } + private Set getField1(String pk_marasstframe) throws DAOException { + List codes = this.queryMarasstCodesByFrameID(pk_marasstframe); + Set allowFields = new HashSet(); + //如果项目被更改项目需要被默认选中 + for(int i = 2; i <= 16; ++i) { + String code = this.getNewCodeOfMarasst(i); + if (codes.contains(code) ) { + allowFields.add("marasst" + code); + } + } + + + return allowFields; + } + private String getNewCodeOfMarasst(int i) { + return i == 16 ? "100" : Integer.toString(i); + } + + + + + + + private List getmarasstframe(String materialVID) throws BusinessException { + String sql = "select pk_marasstframe from " + MaterialVO.getDefaultTableName() + " where pk_material = ? "; + SQLParameter param = new SQLParameter(); + param.addParam(materialVID); + return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor()); + } + + + + + + + + + + + private void updateMaterialCostUpdateAssts(String pk_marasstframe, String materialVID) throws BusinessException { + List materialCostVOs = this.queryMarCostVOsByMaterialPK(materialVID); + if (materialCostVOs != null && materialCostVOs.size() != 0) { + Set allowFields = this.getCostAsstField(pk_marasstframe); + Set notallowFields = this.getnotCostAsstField(pk_marasstframe); + + this.updateMaterialCostAsstByPks(notallowFields,allowFields, materialCostVOs); + } + } + private List queryMarCostVOsByMaterialPK(String pk_material) throws BusinessException { + List voList = new ArrayList(); + String wherePart = "pk_material = '" + pk_material + "'"; + Collection col = this.getMdPersistenceQueryService().queryBillOfVOByCondWithOrder(MaterialCostVO.class, wherePart, false, new String[]{"materialcostmode"}, (String[])null); + if (col != null && col.size() > 0) { + voList.addAll(col); + } + + return voList; + } + public IMDPersistenceQueryService getMdPersistenceQueryService() { + if (this.mdPersistenceQueryService == null) { + this.mdPersistenceQueryService = MDPersistenceService.lookupPersistenceQueryService(); + } + + return this.mdPersistenceQueryService; + } + private Set getCostAsstField(String pk_marasstframe) throws BusinessException { + List codes = this.queryMarasstCodesByFrameID(pk_marasstframe); + Set notAllowFields = new HashSet(); + + for(int i = 2; i <= 16; ++i) { + String code = this.getNewCodeOfMarasst(i); + if (codes.contains(code)) { + notAllowFields.add("marasst" + code); + } + } + + return notAllowFields; + } + private Set getnotCostAsstField(String pk_marasstframe) throws BusinessException { + List codes = this.queryMarasstCodesByFrameID(pk_marasstframe); + Set notAllowFields = new HashSet(); + + for(int i = 2; i <= 16; ++i) { + String code = this.getNewCodeOfMarasst(i); + if (!codes.contains(code)) { + notAllowFields.add("marasst" + code); + } + } + + return notAllowFields; + } + private void updateMaterialCostAsstByPks(Set notAllowFields,Set allowFields, List materialCostVOs) throws BusinessException { + Map pk_cost_map = new HashMap(); + + for(MaterialCostVO materialCostVO : materialCostVOs) { + pk_cost_map.put(materialCostVO.getPrimaryKey(), materialCostVO); + } + + String pk_group = InvocationInfoProxy.getInstance().getGroupId(); + List oldMaterialCostVOs = new ArrayList(); + List oldMaterialCostmodeVOs = new ArrayList(); + + for(MaterialCostVO oldCostVO : pk_cost_map.values()) { + oldMaterialCostVOs.add(oldCostVO); + MaterialCostmodeVO[] costmodeVOs = oldCostVO.getMaterialcostmode(); + if (!ArrayUtils.isEmpty(costmodeVOs)) { + for(MaterialCostmodeVO oldCostmodeVO : costmodeVOs) { +// if (!oldCostmodeVO.getPk_costregion().equals(pk_group)) { + oldMaterialCostmodeVOs.add(oldCostmodeVO); +// } + } + } + } + + List newCostmodeVOs = this.valueChangedCostModeVOs(notAllowFields,allowFields, oldMaterialCostmodeVOs); + if (!newCostmodeVOs.isEmpty()) { + Map> changedCostmodeMap = new HashMap(); + + for(MaterialCostmodeVO maCostmodeVO : newCostmodeVOs) { + List list = (List)changedCostmodeMap.get(maCostmodeVO.getPk_materialcost()); + if (list != null && list.size() != 0) { + list.add(maCostmodeVO); + changedCostmodeMap.put(maCostmodeVO.getPk_materialcost(), list); + } else { + list = new ArrayList(); + list.add(maCostmodeVO); + changedCostmodeMap.put(maCostmodeVO.getPk_materialcost(), list); + } + } + + Set pk_materialcosts = changedCostmodeMap.keySet(); + List newMaterialCostVOs = new ArrayList(); + List newMaterialCostmodeVOs = new ArrayList(); + + for(String pk_materialcost : pk_materialcosts) { + MaterialCostVO newCostVO = (MaterialCostVO)pk_cost_map.get(pk_materialcost); + newMaterialCostVOs.add(newCostVO); + } + + for(List list : changedCostmodeMap.values()) { + newMaterialCostmodeVOs.addAll(list); + } + + this.dispatchUpdateUpdateEvent(oldMaterialCostVOs, oldMaterialCostmodeVOs, newMaterialCostVOs, newMaterialCostmodeVOs, notAllowFields,allowFields); + } + } + private List valueChangedCostModeVOs(Set notAllowFields,Set allowFields, List costmodeVOs) { + List newCostmodeVOs = new ArrayList(); + + for(MaterialCostmodeVO oldcCostmodeVO : costmodeVOs) { + boolean valueChanged = false; + MaterialCostmodeVO newcCostmodeVO = (MaterialCostmodeVO)oldcCostmodeVO.clone(); + + for(String field : allowFields) { + valueChanged = true; + newcCostmodeVO.setAttributeValue(field, UFBoolean.TRUE); + } + for(String field : notAllowFields) { + valueChanged = true; + newcCostmodeVO.setAttributeValue(field, UFBoolean.FALSE); + } + + if (valueChanged) { + newCostmodeVOs.add(newcCostmodeVO); + } + } + + return newCostmodeVOs; + } + private void dispatchUpdateUpdateEvent(List oldMaterialCostVOs, List oldMaterialCostmodeVOs, List newMaterialCostVOs, List newMaterialCostmodeVOs, Set notAllowFields, Set allowFields) throws BusinessException { + BDCommonEventUtil costeventUtil = new BDCommonEventUtil("d0ff92c6-1059-46b4-97fd-ed8b3d0a85d9"); + BDCommonEventUtil costmodeeventUtil = new BDCommonEventUtil("bc230e0a-68c1-4cf9-bd78-58e55953596b"); + costeventUtil.setOldObjs(oldMaterialCostVOs.toArray(new MaterialCostVO[0])); + costeventUtil.dispatchUpdateBeforeEvent(oldMaterialCostVOs.toArray(new MaterialCostVO[0])); + costmodeeventUtil.setOldObjs(oldMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0])); + costmodeeventUtil.dispatchUpdateBeforeEvent(oldMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0])); + this.getBaseDAO().updateVOArray((SuperVO[])newMaterialCostVOs.toArray(new MaterialCostVO[0])); + CacheProxy.fireDataUpdated(MaterialCostVO.getDefaultTableName()); + this.getBaseDAO().updateVOArray((SuperVO[])newMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0]), (String[])notAllowFields.toArray(new String[0])); + this.getBaseDAO().updateVOArray((SuperVO[])newMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0]), (String[])allowFields.toArray(new String[0])); + + CacheProxy.fireDataUpdated(MaterialCostmodeVO.getDefaultTableName()); + costeventUtil.dispatchUpdateAfterEvent(newMaterialCostVOs.toArray(new MaterialCostVO[0])); + costmodeeventUtil.dispatchUpdateAfterEvent(newMaterialCostmodeVOs.toArray(new MaterialCostmodeVO[0])); + } + + + + + + + private void updateMaterialProdAssts(String pk_marasstframe, String materialVID) throws BusinessException { + List pks = this.queryToUpdateProdPks(materialVID); + if (!pks.isEmpty()) { + Set notAllowFields = this.getNotProdAsstField(pk_marasstframe); + this.updateMaterialProdAsstByPks(notAllowFields, pks); + } + } + + private List queryToUpdateProdPks(String materialVID) throws BusinessException { + String sql = "select pk_materialprod from " + MaterialProdVO.getDefaultTableName() + " where pk_material = ? "; + SQLParameter param = new SQLParameter(); + param.addParam(materialVID); + return (List)this.getBaseDAO().executeQuery(sql, param, new ColumnListProcessor()); + } + + private void updateMaterialProdAsstByPks(Set notAllowFields, List pks) throws BusinessException { + Map pk_prod_map = this.queryToUpdateVOsProd(pks); + List newVOs = this.getUpdateProdVOs(notAllowFields, pk_prod_map); + if (!newVOs.isEmpty()) { + MaterialProdVO[] vos = (MaterialProdVO[])newVOs.toArray(new MaterialProdVO[0]); + MaterialProdVO[] oldVOs = this.getOldVOs(vos, pk_prod_map); + BDCommonEventUtil eventUtil = new BDCommonEventUtil("a3133495-8c94-47b4-83d4-0d32bd08ac82"); + eventUtil.setOldObjs(oldVOs); + eventUtil.dispatchUpdateBeforeEvent((Object[])vos); + this.getBaseDAO().updateVOArray(vos, (String[])notAllowFields.toArray(new String[0])); + CacheProxy.fireDataUpdated(MaterialProdVO.getDefaultTableName()); + eventUtil.dispatchUpdateAfterEvent((Object[])vos); + } + } + + private Map queryToUpdateVOsProd(List pks) throws BusinessException { + InSqlBatchCaller caller = new InSqlBatchCaller((String[])pks.toArray(new String[0])); + + try { + return (Map)caller.execute(new IInSqlBatchCallBack() { + Map pk_prod_map = new HashMap(); + + public Object doWithInSql(String inSql) throws BusinessException, SQLException { + Collection col = MaterialAsstFrame1ChangedListener.this.getBaseDAO().retrieveByClause(MaterialProdVO.class, "pk_materialprod in " + inSql); + if (col != null) { + for(MaterialProdVO vo : col) { + this.pk_prod_map.put(vo.getPrimaryKey(), vo); + } + } + + return this.pk_prod_map; + } + }); + } catch (SQLException e) { + Logger.error(e.getMessage(), e); + throw new BusinessException(e.getMessage(), e); + } + } + + private List getUpdateProdVOs(Set notAllowFields, Map pk_prod_map) { + List newVOs = new ArrayList(); + if (pk_prod_map != null && !pk_prod_map.isEmpty()) { + for(MaterialProdVO oldVO : pk_prod_map.values()) { + boolean valueChanged = false; + MaterialProdVO newVO = (MaterialProdVO)oldVO.clone(); + + for(String field : notAllowFields) { +// if (UFBoolean.TRUE.equals(oldVO.getAttributeValue(field))) { + valueChanged = true; + newVO.setAttributeValue(field, UFBoolean.TRUE); +// } + } + + if (valueChanged) { + newVOs.add(newVO); + } + } + + return newVOs; + } else { + return newVOs; + } + } + + private MaterialProdVO[] getOldVOs(MaterialProdVO[] vos, Map pk_prod_map) { + MaterialProdVO[] oldVOs = new MaterialProdVO[vos.length]; + + for(int i = 0; i < vos.length; ++i) { + oldVOs[i] = (MaterialProdVO)pk_prod_map.get(vos[i].getPrimaryKey()); + } + + return oldVOs; + } + + private Set getNotProdAsstField(String pk_marasstframe) throws DAOException { + List codes = this.queryMarasstCodesByFrameID(pk_marasstframe); + Set notAllowFields = new HashSet(); + + for(int i = 2; i <= 16; ++i) { + String code = this.getNewCodeOfMarasst(i); + if (codes.contains(code)) { + notAllowFields.add("costvalutasst" + code); + } + } + + return notAllowFields; + } + + + + +}