fix:
1.报错修复
This commit is contained in:
parent
88ddf7970f
commit
593050d6d5
@ -1,5 +1,6 @@
|
||||
package com.yem.wm.es.shippingdetails.form;
|
||||
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
import com.alibaba.druid.support.logging.Log;
|
||||
import com.alibaba.druid.support.logging.LogFactory;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
@ -14,7 +15,11 @@ import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.IDataModel;
|
||||
import kd.bos.entity.datamodel.events.*;
|
||||
import kd.bos.entity.datamodel.RowDataEntity;
|
||||
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
|
||||
import kd.bos.entity.datamodel.events.AfterDeleteRowEventArgs;
|
||||
import kd.bos.entity.datamodel.events.BeforeDeleteRowEventArgs;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.IFormView;
|
||||
@ -76,6 +81,7 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
||||
IDataModel model = this.getModel();
|
||||
IFormView view = this.getView();
|
||||
String key = e.getOperateKey();
|
||||
Map<String, Object> datas = new HashMap<String, Object>();
|
||||
@ -189,7 +195,7 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
DynamicObject yem_bd_products = dataEntity.getDynamicObject("yem_bd_products");
|
||||
EntryGrid entryGrid = this.getControl("yem_es_materialinfo");
|
||||
//获取选中行,数组为行号,从0开始int[]
|
||||
int selectRows[] = entryGrid.getSelectRows();
|
||||
int[] selectRows = entryGrid.getSelectRows();
|
||||
if (selectRows.length > 0) {
|
||||
for (int selectRow : selectRows) {
|
||||
DynamicObject entryRows = this.getModel().getEntryEntity("yem_es_materialinfo").get(selectRow);
|
||||
@ -270,6 +276,37 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
if ("submit".equals(key)) {
|
||||
this.getView().invokeOperation("refresh");
|
||||
}
|
||||
if ("requestacdeclaration".equals(key)) {
|
||||
EntryGrid control = this.getControl("yem_es_materialinfo");
|
||||
int[] selectRows = control.getSelectRows();
|
||||
if (selectRows.length == 0) {
|
||||
DynamicObjectCollection yemEsMaterialinfo = this.getModel().getEntryEntity("yem_es_materialinfo");
|
||||
for (int i = 0; i < yemEsMaterialinfo.size(); i++) {
|
||||
carryReportCategoryAndHsCode(model, view, i, "");
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i : selectRows) {
|
||||
DynamicObject[] load = getDeclarationElementsUseCarry(model, i, null);
|
||||
if (load.length == 1) {
|
||||
// DynamicObject hscode = (DynamicObject) model.getValue("yem_hscode", i);
|
||||
// carryDeclaration(model, view, i, load[0], hscode);
|
||||
carryReportCategoryAndHsCode(model, view, i, "");
|
||||
} else {
|
||||
if (load.length == 0) {
|
||||
sb.append(String.format("第 %s 行未获匹配申报要素!!", i + 1)).append("\r\n");
|
||||
}
|
||||
if (load.length > 1) {
|
||||
sb.append(String.format("第 %s 行匹配到多条申报要素,请手动选择!!", i + 1)).append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
view.showErrorNotification(sb.toString());
|
||||
} else {
|
||||
view.showSuccessNotification("操作成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -318,6 +355,43 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
|
||||
}
|
||||
}
|
||||
String type = this.getModel().getDataEntityType().getName();
|
||||
if (type.equals("yem_xshippingdetails")) {
|
||||
if ("yem_es_salesorder_p".equals(name)) {
|
||||
RowDataEntity[] rowDataEntities = e.getRowDataEntities();
|
||||
DynamicObjectCollection collects = this.getModel().getEntryEntity("yem_es_salesorder_total");
|
||||
for (RowDataEntity rowDataEntitie : rowDataEntities) {
|
||||
DynamicObject followcar = rowDataEntitie.getDataEntity();
|
||||
DynamicObject newEntryEntity = collects.addNew();
|
||||
newEntryEntity.set("yem_isgifit_tl", true);
|
||||
newEntryEntity.set("yem_classification_tl", "A");
|
||||
if (followcar.getDynamicObject("yem_accessorytype") != null) {
|
||||
newEntryEntity.set("yem_basicmodel_tl", followcar.getLong("yem_accessorytype.id"));
|
||||
}
|
||||
if (StringUtil.isNotEmpty(followcar.getString("yem_volvotype"))) {
|
||||
newEntryEntity.set("yem_volvotype_tl", followcar.getString("yem_volvotype"));
|
||||
}
|
||||
if (followcar.getDynamicObject("yem_accesmaterial") != null) {
|
||||
newEntryEntity.set("yem_accesmaterial_tl", followcar.getLong("yem_accesmaterial.id"));
|
||||
newEntryEntity.set("yem_materialname_tl", followcar.getString("yem_accesmaterial.name"));
|
||||
newEntryEntity.set("yem_materialenname_tl", followcar.getString("yem_accesmaterial.yem_nameen"));
|
||||
newEntryEntity.set("yem_specification_tl", followcar.getString("yem_accesmaterial.modelnum"));
|
||||
}
|
||||
if (followcar.getDynamicObject("yem_acunit") != null) {
|
||||
newEntryEntity.set("yem_acunit_tl", followcar.getLong("yem_acunit.id"));
|
||||
newEntryEntity.set("yem_unitfieldbase_tl", followcar.getLong("yem_acunit.id"));
|
||||
}
|
||||
if (StringUtil.isNotEmpty(followcar.getString("yem_saleorderno_p"))) {
|
||||
newEntryEntity.set("yem_constratnb_tl", followcar.getString("yem_saleorderno_p"));
|
||||
}
|
||||
newEntryEntity.set("yem_qty_tl", followcar.getBigDecimal("yem_acallqty"));
|
||||
newEntryEntity.set("yem_qtybase_tl", followcar.getBigDecimal("yem_acallqty"));
|
||||
newEntryEntity.set("yem_constracteyid_tl", followcar.getLong("yem_constracteyid_p"));
|
||||
newEntryEntity.set("yem_constractioid_tl", followcar.getLong("id"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
super.afterAddRow(e);
|
||||
}
|
||||
|
||||
@ -379,6 +453,33 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("yem_es_materialinfo".equals(name)) {
|
||||
// DynamicObjectCollection collects = this.getModel().getEntryEntity("yem_es_salesorder_total");
|
||||
// List<Integer> ies = new ArrayList<>();
|
||||
// Map<Long,Integer> map1 = new HashMap<>();
|
||||
// for (int i1 = 0; i1 < collects.size(); i1++) {
|
||||
// DynamicObject collect = (DynamicObject) collects.get(i1);
|
||||
// long aLong = collect.getLong("yem_accesmaterial_tl.id");
|
||||
// if (map1.get(aLong) == null){
|
||||
// map1.put(aLong,i1);
|
||||
// }else {
|
||||
// ies.add(i1);
|
||||
// }
|
||||
// }
|
||||
// int[] intArray = ies.stream().mapToInt(Integer::intValue).toArray();
|
||||
// this.getModel().deleteEntryRows("yem_es_salesorder_total",intArray);
|
||||
Boolean aseqty = aseqty();
|
||||
if (aseqty) {
|
||||
this.getView().showMessage("删除单已存在下游单,不允许删除!!!");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
if ("yem_es_salesorder_p".equals(name)) {
|
||||
Boolean aseqty = aseqty(rowIndexs);
|
||||
if (aseqty) {
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -546,30 +647,6 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
case "yem_iswithaccessories":
|
||||
model.setValue("yem_accompanynum", null);
|
||||
break;
|
||||
// case "yem_customclass":
|
||||
//// carryDeclaration(model, this.getView(), rowIndex);
|
||||
// carryReportCategoryAndHsCode(model, this.getView(), rowIndex, "yem_customclass");
|
||||
// break;
|
||||
// case "yem_hscode":
|
||||
// carryReportCategoryAndHsCode(model, this.getView(), rowIndex, "yem_hscode");
|
||||
// if (newValue instanceof DynamicObject) {
|
||||
// DynamicObject yem_hscode = (DynamicObject) newValue;
|
||||
// if (yem_hscode != null) {
|
||||
// String yemUnit = yem_hscode.getString("yem_unit");
|
||||
// DynamicObject bdMeasureunits = BusinessDataServiceHelper.loadSingle("bd_measureunits", "id,number,name"
|
||||
// , new QFilter[]{new QFilter("name", QCP.equals, yemUnit)});
|
||||
// if (bdMeasureunits != null) {
|
||||
// this.getModel().setValue("yem_declareunit",bdMeasureunits,rowIndex);
|
||||
// }else {
|
||||
// this.getModel().setValue("yem_declareunit",null,rowIndex);
|
||||
// }
|
||||
// }else {
|
||||
// this.getModel().setValue("yem_declareunit",null,rowIndex);
|
||||
// }
|
||||
// }else {
|
||||
// this.getModel().setValue("yem_declareunit",null,rowIndex);
|
||||
// }
|
||||
// break;
|
||||
case "yem_hscode":
|
||||
carryReportCategoryAndHsCode(this.getModel(), this.getView(), rowIndex, "yem_hscode");
|
||||
// carryDeclaration(this.getModel(), this.getView(), rowIndex);
|
||||
@ -581,7 +658,7 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
break;
|
||||
// case "yem_qty":
|
||||
case "yem_offeramount":
|
||||
DynamicObjectCollection collection = this.getModel().getEntryEntity("yem_es_salescontrac_s");
|
||||
DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_es_salescontrac_s");
|
||||
for (DynamicObject dynamicObject : collection) {
|
||||
BigDecimal raprate = dynamicObject.getBigDecimal("yem_raprate");
|
||||
BigDecimal offeramount = dataEntity.getBigDecimal("yem_offeramount");
|
||||
@ -595,6 +672,31 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
case "yem_mincabinetnumbers":
|
||||
countSmallCabinetQty(model);//汇总表头小柜数量
|
||||
break;
|
||||
case "yem_qty":
|
||||
DynamicObjectCollection collects = this.getModel().getEntryEntity("yem_es_salesorder_total");
|
||||
List<Integer> ies = new ArrayList<>();
|
||||
Map<Long, Integer> map1 = new HashMap<>();
|
||||
for (int i1 = 0; i1 < collects.size(); i1++) {
|
||||
DynamicObject collect = (DynamicObject) collects.get(i1);
|
||||
DynamicObject yemAccesmaterialTl = collect.getDynamicObject("yem_accesmaterial_tl");
|
||||
if (yemAccesmaterialTl != null) {
|
||||
long aLong = yemAccesmaterialTl.getLong("id");
|
||||
if (map1.get(aLong) == null) {
|
||||
map1.put(aLong, i1);
|
||||
} else {
|
||||
ies.add(i1);
|
||||
}
|
||||
}else {
|
||||
ies.add(i1);
|
||||
}
|
||||
}
|
||||
int[] intArray = ies.stream().mapToInt(Integer::intValue).toArray();
|
||||
this.getModel().deleteEntryRows("yem_es_salesorder_total", intArray);
|
||||
Boolean aseqty = aseqty();
|
||||
if (aseqty) {
|
||||
this.getView().showMessage("数量不允许低于关联调拨数量;,请重新填写");
|
||||
this.getModel().setValue("yem_qty", e.getChangeSet()[0].getOldValue());
|
||||
}
|
||||
case "yem_isdismantlecar":
|
||||
extracted();
|
||||
break;
|
||||
@ -643,7 +745,7 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
this.getModel().setValue("yem_remarks", "", i);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if (!yemEsMaterialinfo.isEmpty()) {
|
||||
for (int i = 0; i < yemEsMaterialinfo.size(); i++) {
|
||||
this.getModel().setValue("yem_remarks", "", i);
|
||||
@ -658,7 +760,78 @@ public class ShippingDetailsFormPlugin extends AbstractBillPlugIn implements Bef
|
||||
}
|
||||
}
|
||||
}
|
||||
//1.是否还需要新增行(1)
|
||||
//随机资料工具新增是否新增行?
|
||||
|
||||
private Boolean aseqty() {
|
||||
if (this.getModel().getDataEntityType().getName().equals("yem_xshippingdetails")) {
|
||||
DynamicObjectCollection yemEsMaterialinfo = this.getModel().getEntryEntity("yem_es_materialinfo");
|
||||
DynamicObjectCollection followcars = this.getModel().getEntryEntity("yem_es_salesorder_p");
|
||||
DynamicObjectCollection yemEsSalesorderTotal = this.getModel().getEntryEntity("yem_es_salesorder_total");
|
||||
Map<Long, BigDecimal> map = new HashMap<>();
|
||||
for (DynamicObject dynamicObject : yemEsMaterialinfo) {
|
||||
String yemBusinesssort = dynamicObject.getString("yem_businesssort");
|
||||
if (!yemBusinesssort.equals("Z")) {
|
||||
Long aLong = dynamicObject.getLong("yem_materiel.id");
|
||||
BigDecimal yemQty = dynamicObject.getBigDecimal("yem_qty");
|
||||
map.merge(aLong, yemQty, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
if (!followcars.isEmpty()) {
|
||||
for (DynamicObject followcar : followcars) {
|
||||
long aLong = followcar.getLong("yem_accesmaterial.id");
|
||||
BigDecimal yemAcallqty = followcar.getBigDecimal("yem_acallqty");
|
||||
map.merge(aLong, yemAcallqty, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
if (yemEsSalesorderTotal.size() > 0) {
|
||||
for (DynamicObject dynamicObject : yemEsSalesorderTotal) {
|
||||
BigDecimal decimal = map.get(dynamicObject.getLong("yem_accesmaterial_tl.id"));
|
||||
if (decimal != null) {
|
||||
BigDecimal yemAllocateqtyTl = dynamicObject.getBigDecimal("yem_allocateqty_tl");
|
||||
if (yemAllocateqtyTl.compareTo(decimal) > 0) {
|
||||
return true;
|
||||
} else {
|
||||
dynamicObject.set("yem_qty_tl", decimal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Boolean aseqty(int[] rowIndexs) {
|
||||
if (this.getModel().getDataEntityType().getName().equals("yem_xshippingdetails")) {
|
||||
Map<Long, BigDecimal> map = new HashMap<>();
|
||||
for (int row : rowIndexs) {
|
||||
DynamicObjectCollection yemEsSalesorderTotal = this.getModel().getEntryEntity("yem_es_salesorder_total");
|
||||
Object yemAccesmaterial = this.getModel().getValue("yem_accesmaterial", row);
|
||||
if (yemAccesmaterial != null) {
|
||||
long aLong = ((DynamicObject) yemAccesmaterial).getLong("id");
|
||||
BigDecimal yemAcallqty = (BigDecimal) this.getModel().getValue("yem_acallqty", row);
|
||||
map.merge(aLong, yemAcallqty, BigDecimal::add);
|
||||
if (!yemEsSalesorderTotal.isEmpty()) {
|
||||
for (int i = 0; i < yemEsSalesorderTotal.size(); i++) {
|
||||
DynamicObject dynamicObject = yemEsSalesorderTotal.get(i);
|
||||
BigDecimal decimal = map.get(dynamicObject.getLong("yem_accesmaterial_tl.id"));
|
||||
if (decimal != null) {
|
||||
BigDecimal yemAllocateqtyTl = dynamicObject.getBigDecimal("yem_allocateqty_tl");
|
||||
if (yemAllocateqtyTl.compareTo(decimal) > 0) {
|
||||
this.getView().showMessage("删除单已存在下游单,不允许删除!!!");
|
||||
return true;
|
||||
} else {
|
||||
this.getModel().deleteEntryRow("yem_es_salesorder_total", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
|
Loading…
Reference in New Issue
Block a user