89 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			89 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Java
		
	
	
	
| package tqq9.lc123.cloud.app.plugin.operate.im;
 | |
| 
 | |
| import com.google.gson.Gson;
 | |
| import kd.bos.dataentity.entity.DynamicObject;
 | |
| import kd.bos.dataentity.entity.DynamicObjectCollection;
 | |
| import kd.bos.entity.ExtendedDataEntity;
 | |
| import kd.bos.entity.ExtendedDataEntitySet;
 | |
| import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
 | |
| import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
 | |
| import kd.bos.logging.Log;
 | |
| import kd.bos.logging.LogFactory;
 | |
| import kd.bos.orm.query.QCP;
 | |
| import kd.bos.orm.query.QFilter;
 | |
| import kd.bos.servicehelper.BusinessDataServiceHelper;
 | |
| import kd.sdk.plugin.Plugin;
 | |
| 
 | |
| import java.math.BigDecimal;
 | |
| import java.util.Date;
 | |
| import java.util.HashMap;
 | |
| import java.util.Map;
 | |
| 
 | |
| /**
 | |
|  * 采购入库转换插件
 | |
|  */
 | |
| public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin {
 | |
| 
 | |
|     private final static Log logger = LogFactory.getLog(PurInConvertPlugin.class);
 | |
|     private static String IM_PURINBILL = "im_purinbill";
 | |
| 
 | |
| 
 | |
|     /**
 | |
|      * 入库回传下推写入对应的
 | |
|      * quantity	入库数量
 | |
|      * manufactureDate	生产日期
 | |
|      * expirationDate	失效期
 | |
|      * batch	批次
 | |
|      * registrationCode	注册证号
 | |
|      * licenceCode	生产许可证号
 | |
|      * producer	生产厂商
 | |
|      * @param e
 | |
|      */
 | |
|     @Override
 | |
|     public void afterConvert(AfterConvertEventArgs e) {
 | |
|         super.afterConvert(e);
 | |
|         ExtendedDataEntitySet targetExtDataEntitySet = e.getTargetExtDataEntitySet();
 | |
|         ExtendedDataEntity[] extendedDataEntities = targetExtDataEntitySet.FindByEntityKey(IM_PURINBILL);
 | |
|         Map<String, String> variables = this.getOption().getVariables();
 | |
|         for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
 | |
|             //采购入库单
 | |
|             DynamicObject dataEntity = extendedDataEntity.getDataEntity();
 | |
|             DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("billentry");
 | |
|             for (DynamicObject entry : dynamicObjectCollection) {
 | |
|                 String srcbillentryid = entry.getString("srcbillentryid");
 | |
|                 //核心单据号一致,写入数据
 | |
|                 if (variables.containsKey(srcbillentryid)) {
 | |
|                     String jsonString = variables.get(srcbillentryid);
 | |
|                     Gson gson = new Gson();
 | |
|                     // 将 JSON 字符串转换为 HashMap
 | |
|                     HashMap<String, Object> jsonMap = gson.fromJson(jsonString, HashMap.class);
 | |
|                     BigDecimal quantity = new BigDecimal(jsonMap.get("quantity").toString());//入库数量
 | |
|                     Double manufacture = (Double) jsonMap.get("manufactureDate");
 | |
|                     Date manufactureDate = new Date(manufacture.longValue()); //生产日期
 | |
|                     Double expiration = (Double) jsonMap.get("expirationDate");
 | |
|                     Date expirationDate = new Date(expiration.longValue()); //失效期
 | |
|                     String batch = jsonMap.get("batch").toString();//批次
 | |
|                     String uniqueCode = jsonMap.get("uniqueCode").toString();//商品编码
 | |
|                     String registrationCode = jsonMap.get("registrationCode").toString();//注册证号
 | |
|                     String licenceCode = jsonMap.get("licenceCode").toString();//生产许可证号
 | |
|                     String producer = jsonMap.get("producer").toString();//生产厂商
 | |
|                     DynamicObject tqq9_goodspackage = BusinessDataServiceHelper.loadSingle("tqq9_goodspackage", new QFilter[]{new QFilter("tqq9_mater.number", QCP.equals, uniqueCode).and("tqq9_isauto", QCP.equals,true)});
 | |
|                     DynamicObject tqq9_registration = BusinessDataServiceHelper.loadSingle("tqq9_registration", new QFilter[]{new QFilter("number", QCP.equals, registrationCode)});
 | |
|                     DynamicObject tqq9_proxyandfactory = BusinessDataServiceHelper.loadSingle("tqq9_proxyandfactory", new QFilter[]{new QFilter("number", QCP.equals, producer)});
 | |
|                     entry.set("qty",quantity);
 | |
|                     entry.set("baseqty",quantity);
 | |
|                     entry.set("tqq9_goods",tqq9_goodspackage);
 | |
|                     entry.set("producedate",manufactureDate);
 | |
|                     entry.set("expirydate",expirationDate);
 | |
|                     entry.set("lotnumber",batch);
 | |
|                     entry.set("tqq9_licenseno",licenceCode);
 | |
|                     entry.set("tqq9_registration",tqq9_registration);
 | |
|                     entry.set("tqq9_proxyandfactory",tqq9_proxyandfactory);
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|     }
 | |
| 
 | |
| } |