81 lines
4.2 KiB
Java
81 lines
4.2 KiB
Java
package tqq9.lc123.cloud.app.plugin.operate.im;
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
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.bos.servicehelper.operation.SaveServiceHelper;
|
|
import kd.sdk.plugin.Plugin;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 采购入库反写批次注册证管理
|
|
*/
|
|
public class PurInIotManagePlugin extends AbstractOperationServicePlugIn implements Plugin {
|
|
private final static Log logger = LogFactory.getLog(PurInIotManagePlugin.class);
|
|
|
|
@Override
|
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
super.afterExecuteOperationTransaction(e);
|
|
//物料Map
|
|
DynamicObject[] materials = BusinessDataServiceHelper.load("bd_material", "id,number,name,tqq9_brand,baseunit,tqq9_brand", null);
|
|
HashMap<Long, DynamicObject> materialMap = new HashMap<Long, DynamicObject>();
|
|
for (DynamicObject dynamicObject : materials) {
|
|
materialMap.put(dynamicObject.getLong("id"), dynamicObject);
|
|
}
|
|
for (DynamicObject dataEntity : e.getDataEntities()) {
|
|
String billno = dataEntity.getString("billno");
|
|
QFilter qFilter = new QFilter("billno", QCP.equals, billno);
|
|
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("im_purinbill",qFilter.toArray());
|
|
DynamicObjectCollection billentry = dynamicObject.getDynamicObjectCollection("billentry");
|
|
DynamicObject[] tqq9_goodlotmanages=new DynamicObject[billentry.size()];
|
|
boolean falg=false;
|
|
for (int i = 0; i < billentry.size(); i++) {
|
|
DynamicObject entry = billentry.get(i);
|
|
DynamicObject tqq9_goodlotmanage = BusinessDataServiceHelper.newDynamicObject("tqq9_goodlotmanage");
|
|
Date producedate = entry.getDate("producedate");//生产日期
|
|
Date expirydate = entry.getDate("expirydate");//到期日期
|
|
String lotnumber = entry.getString("lotnumber");//批号
|
|
DynamicObject tqq9_registration = entry.getDynamicObject("tqq9_registration");//商品注册证
|
|
DynamicObject materialpurch = entry.getDynamicObject("material");//物料采购信息
|
|
DynamicObject masterid = materialpurch.getDynamicObject("masterid");//物料id
|
|
DynamicObject material = materialMap.get(masterid.getLong("id"));//物料
|
|
DynamicObject tqq9_brand = material.getDynamicObject("tqq9_brand");//商品品牌
|
|
String number = material.getString("number");//商品编码
|
|
String name = null;
|
|
if(tqq9_registration!=null){
|
|
name=tqq9_registration.getString("name");
|
|
}
|
|
tqq9_goodlotmanage.set("number",number);//商品编码
|
|
tqq9_goodlotmanage.set("tqq9_lot",lotnumber);//批号
|
|
|
|
tqq9_goodlotmanage.set("name",name);//商品注册证名称
|
|
tqq9_goodlotmanage.set("tqq9_brand",tqq9_brand);//商品品牌
|
|
tqq9_goodlotmanage.set("tqq9_crreatdate",producedate);//生产日期
|
|
tqq9_goodlotmanage.set("tqq9_invaliddate",expirydate);//到期日期
|
|
tqq9_goodlotmanage.set("status","C");//数据状态
|
|
tqq9_goodlotmanage.set("enable","1");//使用状态
|
|
QFilter goodlotmanageF = new QFilter("number", QCP.equals,number);
|
|
goodlotmanageF=goodlotmanageF.and(new QFilter("tqq9_lot", QCP.equals,lotnumber));
|
|
DynamicObject tqq9_goodlotmanage1 = BusinessDataServiceHelper.loadSingle("tqq9_goodlotmanage",goodlotmanageF.toArray());
|
|
if(tqq9_goodlotmanage1==null){
|
|
falg=true;
|
|
tqq9_goodlotmanages[i]=tqq9_goodlotmanage;
|
|
}
|
|
}
|
|
if(falg){
|
|
SaveServiceHelper.save(tqq9_goodlotmanages);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |