This commit is contained in:
parent
3a2f2eba72
commit
21cd42d284
|
|
@ -11,7 +11,6 @@ import kd.bos.entity.ExtendedDataEntity;
|
||||||
import kd.bos.entity.ExtendedDataEntitySet;
|
import kd.bos.entity.ExtendedDataEntitySet;
|
||||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
||||||
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
|
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
|
||||||
import kd.bos.entity.botp.runtime.ConvertConst;
|
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
|
|
@ -59,16 +58,7 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin
|
||||||
super.afterConvert(e);
|
super.afterConvert(e);
|
||||||
ExtendedDataEntitySet targetExtDataEntitySet = e.getTargetExtDataEntitySet();
|
ExtendedDataEntitySet targetExtDataEntitySet = e.getTargetExtDataEntitySet();
|
||||||
ExtendedDataEntity[] extendedDataEntities = targetExtDataEntitySet.FindByEntityKey(IM_PURINBILL);
|
ExtendedDataEntity[] extendedDataEntities = targetExtDataEntitySet.FindByEntityKey(IM_PURINBILL);
|
||||||
|
|
||||||
ExtendedDataEntity[] entities = targetExtDataEntitySet.FindByEntityKey(getTgtMainType().getName());
|
|
||||||
List<DynamicObject> srcRows = (List<DynamicObject>) entities[0].getValue(ConvertConst.ConvExtDataKey_SourceRows);
|
|
||||||
DynamicObject srcRow = srcRows.get(0);
|
|
||||||
Object sourceBillPK = e.getFldProperties().get("id").getValue(srcRow);
|
|
||||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(sourceBillPK, "pm_purrefundapplybill");//采购退货申请单
|
|
||||||
boolean tqq9_isydth = dynamicObject.getBoolean("tqq9_isydth");//是否异地退货
|
|
||||||
|
|
||||||
Map<String, String> variables = this.getOption().getVariables();
|
Map<String, String> variables = this.getOption().getVariables();
|
||||||
if (!tqq9_isydth) {
|
|
||||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||||
//采购入库单
|
//采购入库单
|
||||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||||
|
|
@ -169,64 +159,6 @@ public class PurInConvertPlugin extends AbstractConvertPlugIn implements Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
|
||||||
//采购入库单
|
|
||||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
|
||||||
DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("billentry");
|
|
||||||
ListIterator<DynamicObject> iterator = dynamicObjectCollection.listIterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
DynamicObject entry = iterator.next();
|
|
||||||
String srcbillentryid = entry.getString("srcbillentryid");
|
|
||||||
//核心单据号一致,写入数据
|
|
||||||
if (variables.containsKey(srcbillentryid)) {
|
|
||||||
String jsonString = variables.get(srcbillentryid);
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
List<HashMap<String, Object>> jsonList = null;
|
|
||||||
try {
|
|
||||||
jsonList = objectMapper.readValue(jsonString, objectMapper.getTypeFactory().constructCollectionType(List.class, HashMap.class));
|
|
||||||
} catch (JsonProcessingException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
if (jsonList != null) {
|
|
||||||
dataEntity.set("tqq9_isrebulidlink", true);
|
|
||||||
for (int i = 0; i < jsonList.size(); i++) {
|
|
||||||
HashMap<String, Object> jsonMap = jsonList.get(i);
|
|
||||||
Object materialId = jsonMap.get("materialId");
|
|
||||||
Object qty = jsonMap.get("qty");
|
|
||||||
Object returnEntryId = jsonMap.get("returnEntryId");
|
|
||||||
// BigDecimal price = entry.getBigDecimal("price");//不含税单价
|
|
||||||
// BigDecimal priceandtax = entry.getBigDecimal("priceandtax");//含税单价
|
|
||||||
// 处理第一次逻辑
|
|
||||||
if (i == 0) {
|
|
||||||
// 第一次直接赋值
|
|
||||||
entry.set("qty", qty);
|
|
||||||
// BigDecimal amount =
|
|
||||||
//amount 金额
|
|
||||||
//taxamount 税额
|
|
||||||
//amountandtax 折扣后价税合计
|
|
||||||
DynamicObjectCollection billentry_lk = entry.getDynamicObjectCollection("billentry_lk");
|
|
||||||
billentry_lk.clear();
|
|
||||||
} else {
|
|
||||||
DataEntityPropertyCollection properties = entry.getDataEntityType().getProperties();
|
|
||||||
// 后续循环复制entry并赋值
|
|
||||||
DynamicObject newEntry = new DynamicObject(dynamicObjectCollection.getDynamicObjectType());
|
|
||||||
for (IDataEntityProperty property : properties) {
|
|
||||||
newEntry.set(property.getName(), entry.get(property.getName()));
|
|
||||||
}
|
|
||||||
newEntry.set("qty", qty);
|
|
||||||
|
|
||||||
DynamicObjectCollection billentry_lk = newEntry.getDynamicObjectCollection("billentry_lk");
|
|
||||||
billentry_lk.clear();
|
|
||||||
// 处理完新entry后的逻辑(比如加入集合或其他操作)
|
|
||||||
iterator.add(newEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue