This commit is contained in:
parent
3801851b3a
commit
d86d0fea8e
|
|
@ -0,0 +1,97 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.field.BasedataEdit;
|
||||
import kd.bos.form.field.BasedataPropEdit;
|
||||
import kd.ec.basedata.common.utils.OpenPageUtils;
|
||||
import kd.ec.cost.formplugin.MaterialCostBillPlugin;
|
||||
|
||||
public class MainMaterialCostBillPluginExt extends MaterialCostBillPluginExt {
|
||||
private static final String PROJECT = "project";
|
||||
private static final String EC_PROJECT = "ec_project";
|
||||
|
||||
public MainMaterialCostBillPluginExt() {
|
||||
}
|
||||
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
super.afterCreateNewData(e);
|
||||
BasedataPropEdit costcontrol = (BasedataPropEdit) this.getView().getControl("costcontrol");
|
||||
costcontrol.setMustInput(true);
|
||||
BasedataPropEdit costcontrolmodel = (BasedataPropEdit) this.getView().getControl("costcontrolmodel");
|
||||
costcontrolmodel.setMustInput(true);
|
||||
BasedataPropEdit materialName = (BasedataPropEdit) this.getView().getControl("materialname");
|
||||
materialName.setMustInput(true);
|
||||
}
|
||||
|
||||
protected List<DynamicObject> filterEntryInfo(DynamicObjectCollection materialInfoCols) {
|
||||
List<DynamicObject> list = new ArrayList();
|
||||
Iterator var3 = materialInfoCols.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
DynamicObject info = (DynamicObject) var3.next();
|
||||
if (info.getBoolean("ismainmaterial")) {
|
||||
list.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
BasedataEdit proj = (BasedataEdit) this.getView().getControl("project");
|
||||
if (proj != null) {
|
||||
proj.addBeforeF7ViewDetailListener((beforeF7ViewDetailEvent) -> {
|
||||
beforeF7ViewDetailEvent.setCancel(true);
|
||||
this.getView().showForm(OpenPageUtils.buildBillShowParam(beforeF7ViewDetailEvent.getPkId(), "ec_project"));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
super.propertyChanged(e);
|
||||
ChangeData changeData = e.getChangeSet()[0];
|
||||
String name = e.getProperty().getName();
|
||||
int rowIndex = changeData.getRowIndex();
|
||||
if (StringUtils.equals(name, "project")) {
|
||||
this.controlCostMustInput();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void controlCostMustInput() {
|
||||
int row = this.getModel().getEntryCurrentRowIndex("subentryentity");
|
||||
DynamicObject project = this.getModel().getDataEntity().getDynamicObject("project");
|
||||
if (project != null) {
|
||||
String editOnUnit = project.getString("boqmode");
|
||||
BasedataEdit unitProject = (BasedataEdit) this.getControl("unitproject");
|
||||
HashMap<String, Object> editor = new HashMap();
|
||||
if ("unitproject".equals(editOnUnit)) {
|
||||
unitProject.setMustInput(true);
|
||||
editor.put("mi", "true");
|
||||
} else {
|
||||
unitProject.setMustInput(false);
|
||||
editor.put("mi", "false");
|
||||
}
|
||||
|
||||
this.getView().updateControlMetadata("unitproject", editor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,844 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import kd.bos.bill.OperationStatus;
|
||||
import kd.bos.cache.CacheFactory;
|
||||
import kd.bos.dataentity.entity.DataEntityBase;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.entity.LocaleString;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.ShowType;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.events.HyperLinkClickEvent;
|
||||
import kd.bos.form.events.HyperLinkClickListener;
|
||||
import kd.bos.form.field.AmountEdit;
|
||||
import kd.bos.form.field.BasedataEdit;
|
||||
import kd.bos.form.field.FieldEdit;
|
||||
import kd.bos.form.field.QtyEdit;
|
||||
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.list.ListFilterParameter;
|
||||
import kd.bos.list.ListShowParameter;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.ec.contract.common.utils.CurrencyHelper;
|
||||
import kd.ec.cost.common.enums.BillStatusEnum;
|
||||
import kd.ec.cost.common.enums.PayDirectionEnum;
|
||||
import kd.ec.cost.formplugin.AbstractEccoBillPlugin;
|
||||
import kd.ec.cost.formplugin.MaterialCostBillPlugin;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.xssf.usermodel.DefaultIndexedColorMap;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFColor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class MaterialCostBillPluginExt extends AbstractEccoBillPlugin implements BeforeF7SelectListener, HyperLinkClickListener {
|
||||
private static Log logger = LogFactory.getLog(MaterialCostBillPluginExt.class);
|
||||
private static final String ECCO_MAINMATCOST = "ecco_mainmatcost";
|
||||
private static final String ECMA_MATERIALINBILL = "ecma_materialinbill";
|
||||
private static final String ECMA_MATERIALOUTBILL = "ecma_materialoutbill";
|
||||
private static final String NEWSUBENTRY = "newsubentry";
|
||||
private static final String AUTOGETDATA = "autogetdata";
|
||||
private static final String DELETESUBENTRY = "deletesubentry";
|
||||
private static final String DELETEENTRY = "deleteentry";
|
||||
private static final String EXPORTBILLDETAIL = "exportbilldetail";
|
||||
|
||||
public MaterialCostBillPluginExt() {
|
||||
}
|
||||
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
String key = e.getProperty().getName();
|
||||
ChangeData changeData = e.getChangeSet()[0];
|
||||
int rowIndex = changeData.getRowIndex();
|
||||
DynamicObject cbs;
|
||||
DynamicObject unitproject;
|
||||
switch (key) {
|
||||
case "period":
|
||||
this.onPeriodChange();
|
||||
break;
|
||||
case "project":
|
||||
this.onProjectChange();
|
||||
break;
|
||||
case "splitamount":
|
||||
int index = changeData.getRowIndex();
|
||||
this.calUnSplitAmt(index);
|
||||
this.setCostAmt();
|
||||
break;
|
||||
case "amount":
|
||||
BigDecimal totalAmt = this.sumAmount("subentryentity", "amount");
|
||||
this.getModel().setValue("splitamount", totalAmt, changeData.getParentRowIndex());
|
||||
break;
|
||||
case "resource":
|
||||
this.getModel().setValue("procbs", (Object) null, rowIndex);
|
||||
this.getModel().setValue("ca", (Object) null, rowIndex);
|
||||
DynamicObject resourceItem = (DynamicObject) changeData.getNewValue();
|
||||
if (null != resourceItem) {
|
||||
cbs = resourceItem.getDynamicObject("cbs");
|
||||
if (null != cbs) {
|
||||
Long cbsId = (Long) cbs.getPkValue();
|
||||
unitproject = (DynamicObject) this.getModel().getValue("project");
|
||||
Long projectId = (Long) unitproject.getPkValue();
|
||||
QFilter qFilter = new QFilter("project", "=", projectId);
|
||||
qFilter.and(new QFilter("enterprisecbs", "=", cbsId));
|
||||
DynamicObject[] proCbs = BusinessDataServiceHelper.load("ec_ecbd_pro_cbs", "id", new QFilter[]{qFilter});
|
||||
if (null != proCbs && proCbs.length > 0) {
|
||||
this.getModel().setValue("procbs", proCbs[0], rowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
this.getModel().setValue("ca", resourceItem.getDynamicObject("ca"), rowIndex);
|
||||
}
|
||||
break;
|
||||
case "unitproject":
|
||||
this.getModel().setValue("proboq", (Object) null, rowIndex);
|
||||
break;
|
||||
case "proboq":
|
||||
cbs = (DynamicObject) changeData.getNewValue();
|
||||
DynamicObject unitPro = (DynamicObject) this.getModel().getValue("unitproject", rowIndex);
|
||||
if (cbs != null && unitPro == null) {
|
||||
unitproject = cbs.getDynamicObject("unitproject");
|
||||
if (unitproject != null) {
|
||||
this.getModel().beginInit();
|
||||
this.getModel().setValue("unitproject", unitproject.getPkValue(), rowIndex);
|
||||
this.getModel().endInit();
|
||||
this.getView().updateView("unitproject", rowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
BasedataEdit project = (BasedataEdit) this.getControl("project");
|
||||
BasedataEdit period = (BasedataEdit) this.getControl("period");
|
||||
BasedataEdit proBOQ = (BasedataEdit) this.getControl("proboq");
|
||||
BasedataEdit proCBS = (BasedataEdit) this.getControl("procbs");
|
||||
BasedataEdit rsItem = (BasedataEdit) this.getControl("resource");
|
||||
BasedataEdit unitPro = (BasedataEdit) this.getControl("unitproject");
|
||||
project.addBeforeF7SelectListener(this);
|
||||
period.addBeforeF7SelectListener(this);
|
||||
proBOQ.addBeforeF7SelectListener(this);
|
||||
proCBS.addBeforeF7SelectListener(this);
|
||||
rsItem.addBeforeF7SelectListener(this);
|
||||
unitPro.addBeforeF7SelectListener(this);
|
||||
EntryGrid grid = (EntryGrid) this.getControl("entryentity");
|
||||
grid.addHyperClickListener(this);
|
||||
}
|
||||
|
||||
public void beforeF7Select(BeforeF7SelectEvent event) {
|
||||
String key = event.getProperty().getName();
|
||||
ListShowParameter listShowParameter = (ListShowParameter) event.getFormShowParameter();
|
||||
DynamicObject project;
|
||||
if (StringUtils.equals(key, "proboq")) {
|
||||
project = (DynamicObject) this.getModel().getValue("project");
|
||||
if (project == null) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "MaterialCostBillPlugin_0", "ec-ecco-formplugin", new Object[0]));
|
||||
event.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
DynamicObject unitPro = (DynamicObject) this.getModel().getValue("unitproject", event.getRow());
|
||||
ListFilterParameter listFilterParameter = listShowParameter.getListFilterParameter();
|
||||
if (unitPro != null) {
|
||||
listFilterParameter.getQFilters().add(new QFilter("unitproject", "=", unitPro.getPkValue()));
|
||||
} else {
|
||||
listFilterParameter.getQFilters().add(new QFilter("project", "=", project.getPkValue()));
|
||||
}
|
||||
|
||||
listShowParameter.setFormId("bos_listf7");
|
||||
} else if (StringUtils.equals(key, "procbs")) {
|
||||
project = (DynamicObject) this.getModel().getValue("project");
|
||||
if (null != project) {
|
||||
listShowParameter.setFormId("bos_listf7");
|
||||
ListFilterParameter listFilterParameter = listShowParameter.getListFilterParameter();
|
||||
listFilterParameter.getQFilters().add(new QFilter("project", "=", project.getPkValue()));
|
||||
} else {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "MaterialCostBillPlugin_0", "ec-ecco-formplugin", new Object[0]));
|
||||
event.setCancel(true);
|
||||
}
|
||||
} else if (StringUtils.equals(key, "unitproject")) {
|
||||
project = (DynamicObject) this.getModel().getValue("project");
|
||||
List<Object> unitProIds = new ArrayList();
|
||||
if (project == null) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("请先选择项目。", "MaterialCostBillPlugin_0", "ec-ecco-formplugin", new Object[0]));
|
||||
event.setCancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
project = BusinessDataServiceHelper.loadSingle(project.getPkValue(), "ec_project");
|
||||
DynamicObjectCollection proUnitPros = project.getDynamicObjectCollection("unitproject");
|
||||
Iterator var7 = proUnitPros.iterator();
|
||||
|
||||
while (var7.hasNext()) {
|
||||
DynamicObject entry = (DynamicObject) var7.next();
|
||||
unitProIds.add(entry.getPkValue());
|
||||
}
|
||||
|
||||
String billno = (String) this.getModel().getValue("subbillno", event.getRow());
|
||||
String billname = (String) this.getModel().getValue("subbillname", event.getRow());
|
||||
QFilter filter1 = new QFilter("billno", "=", billno);
|
||||
QFilter filter2 = new QFilter("billname", "=", billname);
|
||||
DynamicObject[] materialInBill = BusinessDataServiceHelper.load("ecma_materialinbill", "id,unitprojectpro", new QFilter[]{filter1, filter2});
|
||||
if (materialInBill.length > 0) {
|
||||
DynamicObject unitprojectpro = materialInBill[0].getDynamicObject("unitprojectpro");
|
||||
if (unitprojectpro != null) {
|
||||
listShowParameter.getListFilterParameter().getQFilters().add(new QFilter("id", "=", unitprojectpro.getPkValue()));
|
||||
}
|
||||
}
|
||||
|
||||
listShowParameter.getListFilterParameter().getQFilters().add(new QFilter("id", "in", unitProIds));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
super.afterCreateNewData(e);
|
||||
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
|
||||
Map<String, Object> customParams = formShowParameter.getCustomParams();
|
||||
Object projectId = customParams.get("projectId");
|
||||
if (null != projectId) {
|
||||
this.getModel().setValue("project", projectId);
|
||||
}
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int year = cal.get(1);
|
||||
int month = cal.get(2) + 1;
|
||||
QFilter yearFilter = new QFilter("periodyear", "=", year);
|
||||
QFilter monthFilter = new QFilter("periodnumber", "=", month);
|
||||
DynamicObject[] peridoArr = (DynamicObject[]) BusinessDataServiceHelper.load("bd_period", "number,name,periodyear,periodnumber", new QFilter[]{yearFilter, monthFilter});
|
||||
if (peridoArr != null && peridoArr.length > 0) {
|
||||
DynamicObject period = peridoArr[0];
|
||||
this.getModel().setValue("period", period);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void beforeBindData(EventObject e) {
|
||||
super.beforeBindData(e);
|
||||
this.controlCostMustInput();
|
||||
}
|
||||
|
||||
private void controlCostMustInput() {
|
||||
int row = this.getModel().getEntryCurrentRowIndex("subentryentity");
|
||||
DynamicObject project = this.getModel().getDataEntity().getDynamicObject("project");
|
||||
if (project != null) {
|
||||
String editOnUnit = project.getString("boqmode");
|
||||
BasedataEdit unitProject = (BasedataEdit) this.getControl("unitproject");
|
||||
HashMap<String, Object> editor = new HashMap();
|
||||
if ("unitproject".equals(editOnUnit)) {
|
||||
unitProject.setMustInput(true);
|
||||
editor.put("mi", "true");
|
||||
} else {
|
||||
unitProject.setMustInput(false);
|
||||
editor.put("mi", "false");
|
||||
}
|
||||
|
||||
this.getView().updateControlMetadata("unitproject", editor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate formOperate = (FormOperate) args.getSource();
|
||||
int subInd;
|
||||
int entryIndex;
|
||||
BigDecimal totalAmt;
|
||||
switch (formOperate.getOperateKey()) {
|
||||
case "newsubentry":
|
||||
int rowIndex = this.getModel().getEntryCurrentRowIndex("entryentity");
|
||||
int rowCount = this.getModel().getEntryRowCount("entryentity");
|
||||
if (rowCount > 0 && rowIndex >= 0) {
|
||||
subInd = this.getModel().createNewEntryRow("subentryentity");
|
||||
this.getModel().setValue("resource", this.getModel().getValue("material", rowIndex), subInd);
|
||||
this.getModel().setValue("subbillname", this.getModel().getValue("entrybillname", rowIndex), subInd);
|
||||
this.getModel().setValue("subbillno", this.getModel().getValue("entrybillno", rowIndex), subInd);
|
||||
if (subInd > 0) {
|
||||
this.getModel().setValue("unitproject", this.getModel().getValue("unitproject", 0, rowIndex), subInd);
|
||||
} else {
|
||||
String billno = (String) this.getModel().getValue("entrybillno", rowIndex);
|
||||
String billname = (String) this.getModel().getValue("entrybillname", rowIndex);
|
||||
QFilter filter1 = new QFilter("billno", "=", billno);
|
||||
QFilter filter2 = new QFilter("billname", "=", billname);
|
||||
String type = (String) this.getModel().getValue("sourcetype", rowIndex);
|
||||
if (StringUtils.equals("OUT", type)) {
|
||||
filter1.and(new QFilter("matbilltype", "=", "materialout"));
|
||||
} else if (StringUtils.equals("IN", type)) {
|
||||
filter1.and(new QFilter("matbilltype", "=", "materialin"));
|
||||
}
|
||||
|
||||
DynamicObject materialInBill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", "id,unitprojectpro", new QFilter[]{filter1, filter2});
|
||||
if (materialInBill != null) {
|
||||
this.getModel().setValue("unitproject", materialInBill.getDynamicObject("unitprojectpro"), subInd, rowIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("请先选中1行采购入库单/领料出库单明细行数据。", "MaterialCostBillPlugin_1", "ec-ecco-formplugin", new Object[0]));
|
||||
args.setCancel(true);
|
||||
}
|
||||
break;
|
||||
case "autogetdata":
|
||||
if (this.judgeCondition()) {
|
||||
this.loadMaterialInfo();
|
||||
this.setCostAmt();
|
||||
}
|
||||
break;
|
||||
case "deletesubentry":
|
||||
subInd = this.getModel().getEntryCurrentRowIndex("subentryentity");
|
||||
int subRowCount = this.getModel().getEntryRowCount("subentryentity");
|
||||
if (subInd >= 0 && subRowCount > 0) {
|
||||
entryIndex = this.getModel().getEntryCurrentRowIndex("entryentity");
|
||||
// BigDecimal totalAmt = this.sumAmount("subentryentity", "amount");//系统源码
|
||||
totalAmt = this.sumAmount("subentryentity", "amount");//二开修改
|
||||
totalAmt = (BigDecimal) this.getModel().getValue("amount", subInd);
|
||||
totalAmt = totalAmt == null ? BigDecimal.ZERO : totalAmt;
|
||||
totalAmt = totalAmt == null ? BigDecimal.ZERO : totalAmt;
|
||||
totalAmt = totalAmt.subtract(totalAmt);
|
||||
this.getModel().setValue("splitamount", totalAmt, entryIndex);
|
||||
}
|
||||
break;
|
||||
case "deleteentry":
|
||||
entryIndex = this.getModel().getEntryCurrentRowIndex("entryentity");
|
||||
int entryRowCount = this.getModel().getEntryRowCount("entryentity");
|
||||
if (entryIndex >= 0 && entryRowCount > 0) {
|
||||
totalAmt = BigDecimal.ZERO;
|
||||
this.getModel().setValue("splitamount", totalAmt, entryIndex);
|
||||
}
|
||||
break;
|
||||
case "exportbilldetail":
|
||||
this.exportBillDetail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void exportBillDetail() {
|
||||
int rowCount = this.getModel().getEntryRowCount("entryentity");
|
||||
if (rowCount <= 0) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("当前分录没有数据。", "MaterialCostBillPlugin_2", "ec-ecco-formplugin", new Object[0]));
|
||||
} else {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
EntryGrid grid = (EntryGrid) this.getView().getControl("entryentity");
|
||||
List<Control> items = grid.getItems();
|
||||
int size = items.size() - 3;
|
||||
String[] title = new String[size];
|
||||
String[] numbers = new String[size];
|
||||
int index = 0;
|
||||
Iterator var9 = items.iterator();
|
||||
|
||||
while (var9.hasNext()) {
|
||||
Control item = (Control) var9.next();
|
||||
FieldEdit column = (FieldEdit) item;
|
||||
if (!StringUtils.equals(column.getKey(), "sourcetype") && !StringUtils.equals(column.getKey(), "materialentryid") && !StringUtils.equals(column.getKey(), "entryisadjust")) {
|
||||
numbers[index] = column.getKey();
|
||||
if (StringUtils.equals(numbers[index], "materialname")) {
|
||||
title[index] = ResManager.loadKDString("资源名称", "MaterialCostBillPlugin_11", "ec-ecco-formplugin", new Object[0]);
|
||||
} else if (StringUtils.equals(numbers[index], "listingkind")) {
|
||||
title[index] = ResManager.loadKDString("资源分组", "MaterialCostBillPlugin_12", "ec-ecco-formplugin", new Object[0]);
|
||||
} else {
|
||||
title[index] = column.getProperty().getDisplayName().getLocaleValue();
|
||||
}
|
||||
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
XSSFSheet sheet = wb.createSheet(ResManager.loadKDString("单据明细", "MaterialCostBillPlugin_5", "ec-ecco-formplugin", new Object[0]));
|
||||
XSSFCellStyle style = wb.createCellStyle();
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
style.setFillForegroundColor(new XSSFColor(new Color(255, 245, 0), new DefaultIndexedColorMap()));
|
||||
style.setAlignment(HorizontalAlignment.CENTER_SELECTION);
|
||||
XSSFCellStyle dataStyle = wb.createCellStyle();
|
||||
dataStyle.setAlignment(HorizontalAlignment.RIGHT);
|
||||
XSSFRow row = sheet.createRow(0);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < size; ++i) {
|
||||
XSSFCell cell = row.createCell(i);
|
||||
cell.setCellValue(title[i]);
|
||||
cell.setCellStyle(style);
|
||||
sheet.setColumnWidth(i, 4024);
|
||||
}
|
||||
|
||||
String number;
|
||||
for (i = 0; i < rowCount; ++i) {
|
||||
XSSFRow cur = sheet.createRow(i + 1);
|
||||
|
||||
XSSFCell dataCell;
|
||||
String cellValue;
|
||||
for (int count = 0; count < numbers.length; dataCell.setCellValue(cellValue)) {
|
||||
number = numbers[count];
|
||||
dataCell = cur.createCell(count++);
|
||||
Object value = this.getModel().getValue(number, i);
|
||||
cellValue = null;
|
||||
if (value != null) {
|
||||
if (value instanceof DynamicObject) {
|
||||
Object name = ((DynamicObject) value).get("name");
|
||||
if (name instanceof LocaleString) {
|
||||
cellValue = ((LocaleString) name).getLocaleValue();
|
||||
} else {
|
||||
cellValue = name.toString();
|
||||
}
|
||||
|
||||
if (StringUtils.equals(number, "material")) {
|
||||
XSSFCell dataPropertyCell = cur.createCell(count++);
|
||||
dataPropertyCell.setCellValue(cellValue);
|
||||
dataPropertyCell = cur.createCell(count++);
|
||||
Object propertyName = ((DynamicObject) value).get("resource.name");
|
||||
if (propertyName != null) {
|
||||
if (propertyName instanceof LocaleString) {
|
||||
dataPropertyCell.setCellValue(((LocaleString) propertyName).getLocaleValue());
|
||||
} else {
|
||||
dataPropertyCell.setCellValue(propertyName.toString());
|
||||
}
|
||||
}
|
||||
|
||||
cellValue = ((DynamicObject) value).getString("number");
|
||||
}
|
||||
} else if (value instanceof BigDecimal) {
|
||||
DynamicObject currency = (DynamicObject) this.getModel().getValue(this.getCurrency());
|
||||
DynamicObject measureunit = this.getModel().getValue("measureunit", i) != null ? (DynamicObject) this.getModel().getValue("measureunit", i) : null;
|
||||
Control control = this.getControl(number);
|
||||
int precision;
|
||||
if (currency != null && control instanceof AmountEdit) {
|
||||
precision = currency.getInt("amtprecision");
|
||||
cellValue = ((BigDecimal) value).setScale(precision, 4).toPlainString();
|
||||
} else if (measureunit != null && control instanceof QtyEdit) {
|
||||
precision = measureunit.getInt("precision");
|
||||
cellValue = ((BigDecimal) value).setScale(precision, 4).toPlainString();
|
||||
} else {
|
||||
cellValue = ((BigDecimal) value).toPlainString();
|
||||
}
|
||||
|
||||
if ("0E-10".equals(cellValue)) {
|
||||
cellValue = "0.00";
|
||||
}
|
||||
|
||||
dataCell.setCellStyle(dataStyle);
|
||||
} else {
|
||||
cellValue = value.toString();
|
||||
}
|
||||
} else {
|
||||
cellValue = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
wb.write(os);
|
||||
} catch (IOException var26) {
|
||||
var26.printStackTrace();
|
||||
}
|
||||
|
||||
byte[] content = os.toByteArray();
|
||||
InputStream in = new ByteArrayInputStream(content);
|
||||
number = CacheFactory.getCommonCacheFactory().getTempFileCache().saveAsUrl(this.getFileName(), in, 5000);
|
||||
this.getView().download(number);
|
||||
if (wb != null) {
|
||||
try {
|
||||
wb.close();
|
||||
} catch (IOException var25) {
|
||||
var25.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected String getFileName() {
|
||||
Object billNumber = this.getModel().getValue("billno");
|
||||
return billNumber != null ? String.format(ResManager.loadKDString("%s材料成本核算-单据明细.xlsx", "MaterialCostBillPlugin_13", "ec-ecco-formplugin", new Object[0]), billNumber.toString()) : ResManager.loadKDString("材料成本核算-单据明细.xlsx", "MaterialCostBillPlugin_14", "ec-ecco-formplugin", new Object[0]);
|
||||
}
|
||||
|
||||
protected boolean judgeCondition() {
|
||||
DynamicObject project = (DynamicObject) this.getModel().getValue("project");
|
||||
DynamicObject period = (DynamicObject) this.getModel().getValue("period");
|
||||
if (project == null) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("工程项目不能为空。", "MaterialCostBillPlugin_8", "ec-ecco-formplugin", new Object[0]));
|
||||
return false;
|
||||
} else if (period == null) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("期间不能为空。", "MaterialCostBillPlugin_9", "ec-ecco-formplugin", new Object[0]));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPeriodChange() {
|
||||
this.getModel().deleteEntryData("entryentity");
|
||||
this.getModel().deleteEntryData("subentryentity");
|
||||
this.setCostAmt();
|
||||
}
|
||||
|
||||
protected void onProjectChange() {
|
||||
this.getModel().deleteEntryData("entryentity");
|
||||
this.getModel().deleteEntryData("subentryentity");
|
||||
this.setCostAmt();
|
||||
}
|
||||
|
||||
protected BigDecimal sumAmount(String entryKey, String col) {
|
||||
BigDecimal totalAmt = BigDecimal.ZERO;
|
||||
int index = this.getModel().getEntryRowCount(entryKey);
|
||||
|
||||
for (int i = 0; i < index; ++i) {
|
||||
BigDecimal splitAmt = (BigDecimal) this.getModel().getValue(col, i);
|
||||
totalAmt = totalAmt.add(splitAmt);
|
||||
}
|
||||
|
||||
return totalAmt;
|
||||
}
|
||||
|
||||
protected void calUnSplitAmt(int index) {
|
||||
BigDecimal totalAmt = (BigDecimal) this.getModel().getValue("totalamount", index);
|
||||
BigDecimal splitTotalAmt = (BigDecimal) this.getModel().getValue("splittotalamount", index);
|
||||
BigDecimal splitAmt = (BigDecimal) this.getModel().getValue("splitamount", index);
|
||||
BigDecimal unSplitAmt = totalAmt.subtract(splitTotalAmt).subtract(splitAmt);
|
||||
this.getModel().setValue("unsplitamount", unSplitAmt, index);
|
||||
}
|
||||
|
||||
protected QFilter[] getInwareFilter(QFilter qFilter) {
|
||||
DynamicObject project = (DynamicObject) this.getModel().getValue("project");
|
||||
DynamicObject period = (DynamicObject) this.getModel().getValue("period");
|
||||
QFilter projectFilter = new QFilter("project", "=", project.getPkValue());
|
||||
QFilter periodFilter = new QFilter("period.enddate", "<=", this.getLastTimeOfDay(period.getDate("enddate")));
|
||||
QFilter commonFilter = (new QFilter("billstatus", "=", BillStatusEnum.AUDIT.getValue())).and(new QFilter("matbilltype", "=", "materialin"));
|
||||
QFilter costFilter = new QFilter("transtype.impactcost", "=", "1");
|
||||
return new QFilter[]{projectFilter, periodFilter, commonFilter, costFilter, qFilter};
|
||||
}
|
||||
|
||||
protected QFilter[] getOutwareFilter(QFilter qFilter) {
|
||||
DynamicObject project = (DynamicObject) this.getModel().getValue("project");
|
||||
DynamicObject period = (DynamicObject) this.getModel().getValue("period");
|
||||
QFilter projectFilter = new QFilter("project", "=", project.getPkValue());
|
||||
QFilter periodFilter = new QFilter("period.enddate", "<=", this.getLastTimeOfDay(period.getDate("enddate")));
|
||||
QFilter commonFilter = (new QFilter("billstatus", "=", BillStatusEnum.AUDIT.getValue())).and(new QFilter("matbilltype", "=", "materialout"));
|
||||
QFilter costFilter = (new QFilter("transtype.impactcost", "=", "1")).and(new QFilter("costtype", "=", "a"));
|
||||
return new QFilter[]{projectFilter, periodFilter, commonFilter, costFilter, qFilter};
|
||||
}
|
||||
|
||||
protected Date getLastTimeOfDay(Date endDate) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(endDate);
|
||||
calendar.set(11, 23);
|
||||
calendar.set(12, 59);
|
||||
calendar.set(13, 59);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
protected QFilter[] getSplitInfoFilter() {
|
||||
DynamicObject project = (DynamicObject) this.getModel().getValue("project");
|
||||
QFilter projectFilter = new QFilter("project", "=", project.getPkValue());
|
||||
QFilter commonFilter = new QFilter("billstatus", "=", BillStatusEnum.AUDIT.getValue());
|
||||
QFilter[] qFilters = new QFilter[]{projectFilter, commonFilter};
|
||||
return qFilters;
|
||||
}
|
||||
|
||||
protected void setCostAmt() {
|
||||
BigDecimal costAmt = this.sumAmount("entryentity", "splitamount");
|
||||
this.getModel().setValue("costamount", costAmt);
|
||||
}
|
||||
|
||||
protected void loadMaterialInfo() {
|
||||
Map<String, QFilter> filterMap = this.getOnWayFilter();
|
||||
DynamicObject[] inMaterialInfoCols = this.getInMaterialInfo((QFilter) filterMap.get(PayDirectionEnum.IN.getValue()));
|
||||
DynamicObject[] outMaterialInfoCols = this.getOutMaterialInfo((QFilter) filterMap.get(PayDirectionEnum.OUT.getValue()));
|
||||
logger.info("将创建的入库单pk: " + (String) Arrays.stream(inMaterialInfoCols).map(DataEntityBase::getPkValue).map(Object::toString).collect(Collectors.joining(",")));
|
||||
logger.info("将创建的出库单pk: " + (String) Arrays.stream(outMaterialInfoCols).map(DataEntityBase::getPkValue).map(Object::toString).collect(Collectors.joining(",")));
|
||||
this.getModel().deleteEntryData("entryentity");
|
||||
this.getModel().deleteEntryData("subentryentity");
|
||||
this.getView().updateView("entryentity");
|
||||
Map<String, BigDecimal> splitAmtMap = this.getHisSpiltAmt();
|
||||
this.getModel().beginInit();
|
||||
this.loadwareInfo(splitAmtMap, outMaterialInfoCols, PayDirectionEnum.OUT.getValue());
|
||||
this.loadwareInfo(splitAmtMap, inMaterialInfoCols, PayDirectionEnum.IN.getValue());
|
||||
this.getModel().endInit();
|
||||
int entryRowCount = this.getModel().getEntryRowCount("entryentity");
|
||||
if (entryRowCount <= 0) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("没有需要分摊的数据。", "MaterialCostBillPlugin_10", "ec-ecco-formplugin", new Object[0]));
|
||||
} else {
|
||||
this.getView().updateView("entryentity");
|
||||
this.getView().updateView("subentryentity");
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, QFilter> getOnWayFilter() {
|
||||
DynamicObject project = (DynamicObject) this.getModel().getValue("project");
|
||||
QFilter filter = new QFilter("project", "=", project.getPkValue());
|
||||
filter.and(new QFilter("billstatus", "!=", BillStatusEnum.AUDIT.getValue()));
|
||||
filter.and(new QFilter("id", "!=", this.getModel().getDataEntity().getPkValue()));
|
||||
Set<String> mateialInBillnos = new HashSet(16);
|
||||
Set<String> mateialOutBillnos = new HashSet(16);
|
||||
String selectPro = "entryentity.entrybillno,entryentity.sourcetype";
|
||||
DynamicObject[] materialCostBills = BusinessDataServiceHelper.load(this.getSourceFormId(), selectPro, new QFilter[]{filter});
|
||||
DynamicObject[] var7 = materialCostBills;
|
||||
int var8 = materialCostBills.length;
|
||||
|
||||
for (int var9 = 0; var9 < var8; ++var9) {
|
||||
DynamicObject bill = var7[var9];
|
||||
DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity");
|
||||
Iterator var12 = entries.iterator();
|
||||
|
||||
while (var12.hasNext()) {
|
||||
DynamicObject entry = (DynamicObject) var12.next();
|
||||
String sourceType = entry.getString("sourcetype");
|
||||
if (StringUtils.equals(sourceType, PayDirectionEnum.OUT.getValue())) {
|
||||
mateialOutBillnos.add(entry.getString("entrybillno"));
|
||||
} else if (StringUtils.equals(sourceType, PayDirectionEnum.IN.getValue())) {
|
||||
mateialInBillnos.add(entry.getString("entrybillno"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QFilter materialInFilter = new QFilter("billno", "not in", mateialInBillnos);
|
||||
QFilter materialOutFilter = new QFilter("billno", "not in", mateialOutBillnos);
|
||||
logger.info("过滤掉已分摊的入库单: " + String.join(",", mateialInBillnos));
|
||||
logger.info("过滤掉已分摊的出库单: " + String.join(",", mateialOutBillnos));
|
||||
HashMap<String, QFilter> filterMap = new HashMap(2);
|
||||
filterMap.put(PayDirectionEnum.IN.getValue(), materialInFilter);
|
||||
filterMap.put(PayDirectionEnum.OUT.getValue(), materialOutFilter);
|
||||
return filterMap;
|
||||
}
|
||||
|
||||
protected List<DynamicObject> filterEntryInfo(DynamicObjectCollection materialInfoCols) {
|
||||
List<DynamicObject> list = new ArrayList();
|
||||
Iterator var3 = materialInfoCols.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
DynamicObject info = (DynamicObject) var3.next();
|
||||
if (info.getBoolean("ismainmaterial")) {
|
||||
list.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
protected String getSourceFormId() {
|
||||
return "ecco_mainmatcost";
|
||||
}
|
||||
|
||||
protected void loadwareInfo(Map<String, BigDecimal> splitAmtMap, DynamicObject[] materialInfoCols, String source) {
|
||||
DynamicObject[] var4 = materialInfoCols;
|
||||
int var5 = materialInfoCols.length;
|
||||
|
||||
for (int var6 = 0; var6 < var5; ++var6) {
|
||||
DynamicObject materialInfo = var4[var6];
|
||||
boolean isMultiCurrency = materialInfo.getBoolean("ismulticurrency");
|
||||
DynamicObjectCollection entryEntity = materialInfo.getDynamicObjectCollection("entryentity");
|
||||
logger.info("创建的出/入库单: " + materialInfo.getString("billname") + "," + materialInfo.getPkValue().toString());
|
||||
Iterator var10 = this.filterEntryInfo(entryEntity).iterator();
|
||||
|
||||
while (var10.hasNext()) {
|
||||
DynamicObject entryRow = (DynamicObject) var10.next();
|
||||
BigDecimal hisSplitAmt = BigDecimal.ZERO;
|
||||
DynamicObject material = entryRow.getDynamicObject("material");
|
||||
DynamicObject measureunit = entryRow.getDynamicObject("measureunit");
|
||||
String key = null;
|
||||
if (material != null) {
|
||||
Long materialId = (Long) material.getPkValue();
|
||||
String billNo = materialInfo.getString("billno");
|
||||
String modelNum = entryRow.getString("modelnum");
|
||||
String batch = entryRow.getString("lot");
|
||||
String unitId = measureunit != null ? measureunit.getString("id") : "";
|
||||
key = billNo + materialId + modelNum + batch + unitId + entryRow.getPkValue();
|
||||
}
|
||||
|
||||
if (splitAmtMap != null && splitAmtMap.containsKey(key)) {
|
||||
hisSplitAmt = (BigDecimal) splitAmtMap.get(key);
|
||||
}
|
||||
|
||||
BigDecimal totalAmount = entryRow.getBigDecimal("amount");
|
||||
BigDecimal splitAmount = BigDecimal.ZERO;
|
||||
BigDecimal unSplitAmt = BigDecimal.ZERO;
|
||||
DynamicObject stdCurrency;
|
||||
if (isMultiCurrency) {
|
||||
DynamicObject currency = materialInfo.getDynamicObject("currency");
|
||||
stdCurrency = materialInfo.getDynamicObject("stdcurrency");
|
||||
DynamicObject exrateTable = materialInfo.getDynamicObject("exratetable");
|
||||
BigDecimal exchangeRate = materialInfo.getBigDecimal("exchangerate");
|
||||
DynamicObject thisCurrency = this.getModel().getDataEntity().getDynamicObject("currency");
|
||||
if (currency != null && thisCurrency != null) {
|
||||
if (stdCurrency.getPkValue().equals(thisCurrency.getPkValue())) {
|
||||
totalAmount = totalAmount.multiply(exchangeRate);
|
||||
} else if (!currency.getPkValue().equals(thisCurrency.getPkValue())) {
|
||||
exchangeRate = CurrencyHelper.getExChangeRate(currency.getLong("id"), stdCurrency.getLong("id"), exrateTable.getLong("id"), new Date());
|
||||
totalAmount = totalAmount.multiply(exchangeRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hisSplitAmt.compareTo(totalAmount) == 0) {
|
||||
logger.info("已经分摊完毕源分录pk: " + entryRow.getPkValue().toString());
|
||||
} else {
|
||||
splitAmount = totalAmount.subtract(hisSplitAmt);
|
||||
unSplitAmt = totalAmount.subtract(hisSplitAmt).subtract(splitAmount);
|
||||
logger.info("新建的源分录pk: " + entryRow.getPkValue().toString());
|
||||
int index = this.getModel().createNewEntryRow("entryentity");
|
||||
stdCurrency = this.getModel().getEntryRowEntity("entryentity", index);
|
||||
stdCurrency.set("entrybillno", materialInfo.getString("billno"));
|
||||
stdCurrency.set("entrybillname", materialInfo.getString("billname"));
|
||||
stdCurrency.set("material", entryRow.getDynamicObject("material"));
|
||||
stdCurrency.set("modelnum", entryRow.get("modelnum"));
|
||||
stdCurrency.set("batch", entryRow.get("lot"));
|
||||
stdCurrency.set("entryperiod", materialInfo.get("period"));
|
||||
stdCurrency.set("checkoutqty", entryRow.get("qty"));
|
||||
stdCurrency.set("checkoutprice", entryRow.get("price"));
|
||||
stdCurrency.set("measureunit", entryRow.get("measureunit"));
|
||||
stdCurrency.set("totalamount", totalAmount);
|
||||
stdCurrency.set("splittotalamount", hisSplitAmt);
|
||||
stdCurrency.set("sourcetype", source);
|
||||
stdCurrency.set("materialentryid", entryRow.getPkValue());
|
||||
this.loadItemInfo(materialInfo, entryRow, splitAmount, index);
|
||||
stdCurrency.set("splitamount", splitAmount);
|
||||
stdCurrency.set("unsplitamount", unSplitAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected Map<String, BigDecimal> getHisSpiltAmt() {
|
||||
QFilter[] qFilters = this.getSplitInfoFilter();
|
||||
String selectPro = "entryentity.materialentryid,entryentity.entrybillno,entryentity.modelnum,entryentity.batch,entryentity.splitamount,entryentity.material";
|
||||
DynamicObject[] materialCostCols = BusinessDataServiceHelper.load(this.getSourceFormId(), selectPro, qFilters);
|
||||
if (materialCostCols != null && materialCostCols.length > 0) {
|
||||
Map<String, BigDecimal> hisSplitAmtMap = new HashMap(16);
|
||||
DynamicObject[] var5 = materialCostCols;
|
||||
int var6 = materialCostCols.length;
|
||||
|
||||
for (int var7 = 0; var7 < var6; ++var7) {
|
||||
DynamicObject materialCost = var5[var7];
|
||||
DynamicObjectCollection entries = materialCost.getDynamicObjectCollection("entryentity");
|
||||
if (entries != null && !entries.isEmpty()) {
|
||||
Iterator var10 = entries.iterator();
|
||||
|
||||
while (var10.hasNext()) {
|
||||
DynamicObject info = (DynamicObject) var10.next();
|
||||
DynamicObject material = info.getDynamicObject("material");
|
||||
String materialentryid = info.getString("materialentryid");
|
||||
if (material != null) {
|
||||
Long materialId = (Long) material.getPkValue();
|
||||
String billNo = info.getString("entrybillno");
|
||||
String modelNum = info.getString("modelnum");
|
||||
String batch = info.getString("batch");
|
||||
DynamicObject unit = null;
|
||||
DynamicObject[] materialinventry = BusinessDataServiceHelper.load("ecma_materialinventry", "measureunit", new QFilter[]{new QFilter("id", "=", Long.valueOf(materialentryid))});
|
||||
if (materialinventry.length > 0) {
|
||||
unit = materialinventry[0].getDynamicObject("measureunit");
|
||||
}
|
||||
|
||||
String unitid = unit != null ? unit.getString("id") : "";
|
||||
String key = billNo + materialId + modelNum + batch + unitid + materialentryid;
|
||||
BigDecimal splitAmt = info.getBigDecimal("splitamount");
|
||||
if (hisSplitAmtMap.containsKey(key)) {
|
||||
hisSplitAmtMap.put(key, splitAmt.add((BigDecimal) hisSplitAmtMap.get(key)));
|
||||
} else {
|
||||
hisSplitAmtMap.put(key, splitAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hisSplitAmtMap;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadItemInfo(DynamicObject billObj, DynamicObject entryRow, BigDecimal totalAmt, int index) {
|
||||
String billNo = billObj.getString("billno");
|
||||
String billName = billObj.getString("billname");
|
||||
this.getModel().setEntryCurrentRowIndex("entryentity", index);
|
||||
this.getModel().deleteEntryData("subentryentity");
|
||||
int subIndex = this.getModel().createNewEntryRow("subentryentity");
|
||||
DynamicObject entryRowEntity = this.getModel().getEntryRowEntity("subentryentity", subIndex);
|
||||
entryRowEntity.set("subbillno", billNo);
|
||||
entryRowEntity.set("subbillname", billName);
|
||||
entryRowEntity.set("unitproject", billObj.getDynamicObject("unitprojectpro"));
|
||||
entryRowEntity.set("resource", entryRow.getDynamicObject("material"));
|
||||
entryRowEntity.set("proboq", entryRow.getDynamicObject("proboq"));
|
||||
entryRowEntity.set("ca", entryRow.getDynamicObject("ca"));
|
||||
entryRowEntity.set("procbs", entryRow.getDynamicObject("procbs"));
|
||||
entryRowEntity.set("amount", totalAmt);
|
||||
}
|
||||
|
||||
protected DynamicObject[] getInMaterialInfo(QFilter qFilter) {
|
||||
QFilter[] qFilters = this.getInwareFilter(qFilter);
|
||||
String selectPro = "billno,billname,ismulticurrency,currency,stdcurrency,unitprojectpro,exchangerate,exratetable,transtype.impactcost,project,period,entryentity.material,entryentity.noteentryentity.lotid,entryentity.lot,entryentity.modelnum,entryentity.measureunit,entryentity.ismainmaterial,entryentity.amount,entryentity.totalamount,entryentity.procbs,entryentity.ca,entryentity.proboq,entryentity.unitproject,entryentity.qty,entryentity.price";
|
||||
return BusinessDataServiceHelper.load("ecma_materialinbill", selectPro, qFilters);
|
||||
}
|
||||
|
||||
protected DynamicObject[] getOutMaterialInfo(QFilter qFilter) {
|
||||
QFilter[] qFilters = this.getOutwareFilter(qFilter);
|
||||
String selectPro = "billno,billname,ismulticurrency,unitprojectpro,currency,stdcurrency,exchangerate,exratetable,transtype.impactcost,costtype,project,period,entryentity.material,entryentity.lot,entryentity.lotid,entryentity.modelnum,entryentity.measureunit,entryentity.amount,entryentity.ismainmaterial,entryentity.procbs,entryentity.ca,entryentity.proboq,entryentity.unitproject,entryentity.qty,entryentity.price";
|
||||
return BusinessDataServiceHelper.load("ecma_materialoutbill", selectPro, qFilters);
|
||||
}
|
||||
|
||||
public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) {
|
||||
String fieldName = hyperLinkClickEvent.getFieldName();
|
||||
int rowIndex = hyperLinkClickEvent.getRowIndex();
|
||||
if (StringUtils.equals(fieldName, "entrybillname") || StringUtils.equals(fieldName, "entrybillno")) {
|
||||
String billno = (String) this.getModel().getValue("entrybillno", rowIndex);
|
||||
String billname = (String) this.getModel().getValue("entrybillname", rowIndex);
|
||||
QFilter filter1 = new QFilter("billno", "=", billno);
|
||||
QFilter filter2 = new QFilter("billname", "=", billname);
|
||||
QFilter filter3 = new QFilter("transtype.impactcost", "=", true);
|
||||
DynamicObject[] materialInBill = BusinessDataServiceHelper.load("ecma_materialinbill", "id,matbilltype,transtype", new QFilter[]{filter1, filter2, filter3});
|
||||
if (materialInBill.length > 0) {
|
||||
Map<String, Object> settleParam = new HashMap();
|
||||
settleParam.put("pkId", String.valueOf(materialInBill[0].getPkValue()));
|
||||
if ("materialin".equals(materialInBill[0].getString("matbilltype"))) {
|
||||
settleParam.put("formId", "ecma_materialinbill");
|
||||
} else {
|
||||
settleParam.put("formId", "ecma_materialoutbill");
|
||||
}
|
||||
|
||||
FormShowParameter param = FormShowParameter.createFormShowParameter(settleParam);
|
||||
param.getOpenStyle().setShowType(ShowType.MainNewTabPage);
|
||||
param.setStatus(OperationStatus.VIEW);
|
||||
this.getView().showForm(param);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue