package tqq9.lc123.cloud.app.plugin.form.sys; import kd.bos.bill.AbstractBillPlugIn; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.datamodel.events.ChangeData; import kd.bos.entity.datamodel.events.PropertyChangedArgs; import tqq9.lc123.cloud.app.plugin.utils.BaseDataMatchUtils; import java.util.Date; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; /** * 根据物料获取商品信息 */ public class GetGoodsByMaterialBillPlugin extends AbstractBillPlugIn { private static Set materialFieldNameSet_1; private static Set materialFieldNameSet_2; private static Set materialFieldNameSet_3; static{ materialFieldNameSet_1 = Stream.of("pm_purorderbill", "pm_receiptnotice", "im_purinbill", "sm_salorder", "sm_delivernotice", "im_saloutbill", "im_otheroutbill", "tqq9_otherinapply", "im_otherinbill", "im_adjustbill", "tqq9_shortagebill").collect(Collectors.toSet());//material materialFieldNameSet_2 = Stream.of("ar_busbill", "ar_finarbill", "ap_payapply", "ar_busbill", "ar_finarbill").collect(Collectors.toSet());//e_material materialFieldNameSet_3 = Stream.of("tqq9_otheroutapply").collect(Collectors.toSet());//tqq9_materiel } @Override public void propertyChanged(PropertyChangedArgs e) { super.propertyChanged(e); ChangeData[] changeSet = e.getChangeSet(); int rowIndex = changeSet[0].getRowIndex(); String name = e.getProperty().getName(); String materialFieldName = "material"; DynamicObject dataEntity = this.getModel().getDataEntity(true); String dataEntityName = dataEntity.getDataEntityType().getName(); if(materialFieldNameSet_1.contains(dataEntityName)){ materialFieldName = "material"; }else if (materialFieldNameSet_2.contains(dataEntityName)){ materialFieldName = "e_material"; }else if (materialFieldNameSet_3.contains(dataEntityName)){ materialFieldName = "tqq9_materiel"; } if(materialFieldName.equals(name) || "lotnumber".equals(name) || "producedate".equals(name) || "expirydate".equals(name)){ DynamicObject material = (DynamicObject) this.getModel().getValue(materialFieldName, rowIndex); String lotnumber = (String) this.getModel().getValue("lotnumber", rowIndex); Date producedate = (Date) this.getModel().getValue("producedate", rowIndex); Date expirydate = (Date) this.getModel().getValue("expirydate", rowIndex); if(material != null){ DynamicObject[] goodsArr = BaseDataMatchUtils.materialMatchGoods(material.getString("number"), lotnumber, producedate, expirydate, false); this.getModel().setValue("tqq9_goods", goodsArr[0], rowIndex); } } // 形态转换单子明细 if("im_adjustbill".equals(dataEntityName) ){ int parentRowIndex = changeSet[0].getParentRowIndex(); if ("material1".equals(name) || "lotnumber".equals(name) || "producedate".equals(name) || "expirydate".equals(name)){ DynamicObject material = (DynamicObject) this.getModel().getValue("material1", rowIndex); String lotnumber = (String) this.getModel().getValue("lotnumber", rowIndex); Date producedate = (Date) this.getModel().getValue("producedate", rowIndex); Date expirydate = (Date) this.getModel().getValue("expirydate", rowIndex); if(material != null){ DynamicObject[] goodsArr = BaseDataMatchUtils.materialMatchGoods(material.getString("number"), lotnumber, producedate, expirydate, false); this.getModel().setValue("tqq9_goods", goodsArr[0], rowIndex, parentRowIndex); } } } } }