根据物料 批号,生产日期,到期日期查询商品
This commit is contained in:
		
							parent
							
								
									bae67f370a
								
							
						
					
					
						commit
						b357c2c27c
					
				|  | @ -213,13 +213,13 @@ public class WMSAdjustBillController { | |||
|                 materialinv = BusinessDataServiceHelper.loadSingle(materialinv.getPkValue(), "bd_materialinventoryinfo"); | ||||
|                 //调整前商品 | ||||
|                 DynamicObject oGoods = null; | ||||
|                 DynamicObject[] oGoodsArr = BaseDataMatchUtils.materialMatchGoods(cInvCode, cOBatch, true); | ||||
|                 DynamicObject[] oGoodsArr = BaseDataMatchUtils.materialMatchGoods(cInvCode, cOBatch, dOMDate, dOVDate, true); | ||||
|                 if(oGoodsArr != null && oGoodsArr.length > 0){ | ||||
|                     oGoods = oGoodsArr[0]; | ||||
|                 } | ||||
|                 //调整后商品 | ||||
|                 DynamicObject iGoods = null; | ||||
|                 DynamicObject[] iGoodsArr = BaseDataMatchUtils.materialMatchGoods(cInvCode, cIBatch, true); | ||||
|                 DynamicObject[] iGoodsArr = BaseDataMatchUtils.materialMatchGoods(cInvCode, cIBatch, dIMDate, dIVDate, true); | ||||
|                 if(iGoodsArr != null && iGoodsArr.length > 0){ | ||||
|                     iGoods = iGoodsArr[0]; | ||||
|                 } | ||||
|  | @ -456,7 +456,7 @@ public class WMSAdjustBillController { | |||
|             String remark = ckObj.getString("remark");//备注 | ||||
|             //调整前商品 | ||||
|             DynamicObject oGoods = null; | ||||
|             DynamicObject[] oGoodsArr = BaseDataMatchUtils.materialMatchGoods(itemCode, batchCode, true); | ||||
|             DynamicObject[] oGoodsArr = BaseDataMatchUtils.materialMatchGoods(itemCode, batchCode, productDate, expireDate, true); | ||||
|             if(oGoodsArr != null && oGoodsArr.length > 0){ | ||||
|                 oGoods = oGoodsArr[0]; | ||||
|             }else{ | ||||
|  | @ -464,9 +464,13 @@ public class WMSAdjustBillController { | |||
|             } | ||||
| 
 | ||||
|             String batchCode_e = rkObj.getString("batchCode");//入库批号 | ||||
|             //调整后生产日期 | ||||
|             Date productDate_e = rkObj.getDate("productDate"); | ||||
|             //调整后有效期 | ||||
|             Date expireDate_e = rkObj.getDate("expireDate"); | ||||
|             //调整后商品 | ||||
|             DynamicObject iGoods = null; | ||||
|             DynamicObject[] iGoodsArr = BaseDataMatchUtils.materialMatchGoods(itemCode, batchCode_e, true); | ||||
|             DynamicObject[] iGoodsArr = BaseDataMatchUtils.materialMatchGoods(itemCode, batchCode_e, productDate, expireDate, true); | ||||
|             if(iGoodsArr != null && iGoodsArr.length > 0){ | ||||
|                 iGoods = iGoodsArr[0]; | ||||
|             }else{ | ||||
|  | @ -486,10 +490,6 @@ public class WMSAdjustBillController { | |||
|                 } | ||||
|             } | ||||
|             int quantity_e = rkObj.getInteger("quantity"); | ||||
|             //调整后生产日期 | ||||
|             Date productDate_e = rkObj.getDate("productDate"); | ||||
|             //调整后有效期 | ||||
|             Date expireDate_e = rkObj.getDate("expireDate"); | ||||
| 
 | ||||
|             //常量准备-查询单据类型 | ||||
|             QFilter f = new QFilter("number", "=", "im_Adjustbill_STD_BT_S"); | ||||
|  |  | |||
|  | @ -0,0 +1,74 @@ | |||
| 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<String> materialFieldNameSet_1; | ||||
|     private static Set<String> materialFieldNameSet_2; | ||||
|     private static Set<String> materialFieldNameSet_3; | ||||
|     static{ | ||||
|         materialFieldNameSet_1 = Stream.of("im_purinbill", "sm_salorder", "sm_delivernotice", "im_saloutbill", | ||||
|                 "im_otheroutbill", "tqq9_otherinapply", "im_otherinbill", "im_adjustbill").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); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -7,6 +7,7 @@ import org.apache.poi.util.ArrayUtil; | |||
| import scala.Dynamic; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  | @ -30,19 +31,32 @@ public class BaseDataMatchUtils { | |||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 根据物料编码查找对应商品 | ||||
|      * @param materialNumber    物料编码 | ||||
|      * @param lotNumber         批号 | ||||
|      * @param isauto            是否自动封装的商品 | ||||
|      * | ||||
|      * @param materialNumber | ||||
|      * @param lotNumber | ||||
|      * @param producedate | ||||
|      * @param expirydate | ||||
|      * @param isauto | ||||
|      * @return | ||||
|      */ | ||||
|     public static DynamicObject[] materialMatchGoods(String materialNumber, String lotNumber, boolean isauto){ | ||||
|     public static DynamicObject[] materialMatchGoods(String materialNumber, String lotNumber, Date producedate, Date expirydate, boolean isauto){ | ||||
|         QFilter f1 = new QFilter("tqq9_mater.number", "=", materialNumber); | ||||
|         QFilter f2 = new QFilter("tqq9_entry.tqq9_lot.number", "=", lotNumber); | ||||
|         QFilter f3 = new QFilter("tqq9_isauto", "=", isauto); | ||||
|         DynamicObject[] goodsA = BusinessDataServiceHelper.load("tqq9_goodspackage", | ||||
|         QFilter f3 = new QFilter("tqq9_entry.producedate", "=", producedate); | ||||
|         QFilter f4 = new QFilter("tqq9_entry.expirydate", "=", expirydate); | ||||
|         QFilter f5 = new QFilter("tqq9_isauto", "=", isauto); | ||||
|         DynamicObject[] goodsA = null; | ||||
|         if(isauto){ | ||||
|             // 只取自动封装的商品 | ||||
|             goodsA = BusinessDataServiceHelper.load("tqq9_goodspackage", | ||||
|                     "id,number,name,tqq9_mater.baseunit,tqq9_mater.modelnum,tqq9_isauto", | ||||
|                 new QFilter[]{f1, f2, f3}); | ||||
|                     new QFilter[]{f1, f2, f3, f4, f5}); | ||||
|         }else{ | ||||
|             // 取所有的商品 | ||||
|             goodsA = BusinessDataServiceHelper.load("tqq9_goodspackage", | ||||
|                     "id,number,name,tqq9_mater.baseunit,tqq9_mater.modelnum,tqq9_isauto", | ||||
|                     new QFilter[]{f1, f2, f3, f4}); | ||||
|         } | ||||
|         if(goodsA != null && goodsA.length > 0){ | ||||
|             List<DynamicObject> goodsList = new ArrayList<>(); | ||||
|             for (DynamicObject goods : goodsA) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue