diff --git a/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java b/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java index 338cc0b..2aee909 100644 --- a/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java +++ b/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java @@ -5,11 +5,24 @@ import com.alibaba.fastjson.JSONObject; import kd.bos.bill.AbstractBillPlugIn; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.utils.ObjectUtils; import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.datamodel.IDataModel; import kd.bos.entity.param.CustomParam; +import kd.bos.form.CloseCallBack; import kd.bos.form.FormShowParameter; +import kd.bos.form.IFormView; +import kd.bos.form.ShowFormHelper; +import kd.bos.form.control.Control; import kd.bos.form.control.events.ItemClickEvent; import kd.bos.form.events.AfterDoOperationEventArgs; +import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.MulBasedataEdit; +import kd.bos.form.field.RefBillEdit; +import kd.bos.form.field.events.BeforeF7SelectEvent; +import kd.bos.form.field.events.BeforeF7SelectListener; +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.QCP; @@ -18,22 +31,39 @@ import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; import java.math.BigDecimal; -import java.util.Date; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * 返利规则表单插件 * 同步采购合同信息 */ -public class RebateRulesBillPlugin extends AbstractBillPlugIn implements Plugin { +public class RebateRulesBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener { private final static Log logger = LogFactory.getLog(RebateRulesBillPlugin.class); @Override public void registerListener(EventObject e) { super.registerListener(e); this.addItemClickListeners("tbmain"); + MulBasedataEdit control = this.getControl("tqq9_exclunopur"); + control.addBeforeF7SelectListener(this); + } + + @Override + public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) { + IDataModel model = this.getModel(); + String tqq9_excludnum = model.getDataEntity().getString("tqq9_excludnum"); + Date tqq9_startexcludate = model.getDataEntity().getDate("tqq9_startexcludate"); + Date tqq9_endexcludate = model.getDataEntity().getDate("tqq9_endexcludate"); + if (tqq9_startexcludate == null || tqq9_endexcludate == null) { + beforeF7SelectEvent.setCancel(true); + this.getView().showMessage("请先填写排除时间段"); + } + if (StringUtils.equals("1", tqq9_excludnum)) { + ListShowParameter param = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter(); + QFilter qF1 = new QFilter("biztime", QCP.large_equals, tqq9_startexcludate); + QFilter qF2 = new QFilter("biztime", QCP.less_equals, tqq9_endexcludate); + param.getListFilterParameter().getQFilters().add(qF1.and(qF2)); + } } @Override @@ -48,9 +78,9 @@ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements Plugin Object tqq9_estimatepro = this.getModel().getValue("tqq9_estimatepro"); Object tqq9_rebatebrand = this.getModel().getValue("tqq9_rebatebrand"); Object tqq9_rebategoods = this.getModel().getValue("tqq9_rebategoods"); - if(name==null||tqq9_supplier==null||tqq9_startdate==null||tqq9_enddate==null||tqq9_estimatepro==null||tqq9_rebatebrand==null||tqq9_rebategoods==null){ + if (name == null || tqq9_supplier == null || tqq9_startdate == null || tqq9_enddate == null || tqq9_estimatepro == null || tqq9_rebatebrand == null || tqq9_rebategoods == null) { this.getView().showErrorNotification("请确认必录项是否为空"); - }else{ + } else { DynamicObject dataEntity = this.getModel().getDataEntity(true); HashMap map = new HashMap<>(); map.put("tqq9_pur_rebate", dataEntity); @@ -65,7 +95,7 @@ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements Plugin // 获取当前页面的FormShowParameter对象 FormShowParameter formShowParameter = this.getView().getFormShowParameter(); // 获取自定义参数 - String billno =formShowParameter.getCustomParam("purcontract_billno"); + String billno = formShowParameter.getCustomParam("purcontract_billno"); JSONObject purcontract_supplier = formShowParameter.getCustomParam("purcontract_supplier"); JSONArray purcontract_tqq9_dxpp = formShowParameter.getCustomParam("purcontract_tqq9_dxpp"); DynamicObject supplier = null; @@ -80,7 +110,7 @@ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements Plugin } if (purcontract_tqq9_dxpp != null) { for (int i = 0; i < purcontract_tqq9_dxpp.size(); i++) { - JSONObject jsonObject = (JSONObject)purcontract_tqq9_dxpp.get(i); + JSONObject jsonObject = (JSONObject) purcontract_tqq9_dxpp.get(i); JSONObject fbasedataid = jsonObject.getJSONObject("fbasedataid"); String number = fbasedataid.getString("number"); DynamicObject tqq9_dxpp = BusinessDataServiceHelper.loadSingle("tqq9_brand", new QFilter[]{new QFilter("number", QCP.equals, number)}); @@ -105,18 +135,5 @@ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements Plugin } -// @Override -// public void itemClick(ItemClickEvent evt) { -// super.itemClick(evt); -// String itemKey = evt.getItemKey(); -// if (StringUtils.equals("tqq9_confirm", itemKey)) { -// DynamicObject dataEntity = this.getModel().getDataEntity(true); -// HashMap map = new HashMap<>(); -// map.put("tqq9_pur_rebate", dataEntity); -// this.getView().returnDataToParent(map); -// this.getView().close(); -// } -// } - } \ No newline at end of file diff --git a/lc123/cloud/app/plugin/form/pm/PurApplyBillPlugin.java b/lc123/cloud/app/plugin/form/pm/PurApplyBillPlugin.java index b9e321d..e3f776c 100644 --- a/lc123/cloud/app/plugin/form/pm/PurApplyBillPlugin.java +++ b/lc123/cloud/app/plugin/form/pm/PurApplyBillPlugin.java @@ -10,6 +10,8 @@ import kd.bos.form.IFormView; import kd.sdk.plugin.Plugin; import tqq9.lc123.cloud.app.plugin.utils.EntryFieldRefresher; +import java.math.BigDecimal; + /** * 单据界面插件 */ @@ -28,13 +30,14 @@ public class PurApplyBillPlugin extends AbstractBillPlugIn implements Plugin { DynamicObject dataEntity = this.getModel().getDataEntity(true); IDataModel model = this.getModel(); IFormView view = this.getView(); + //--------------上海------------------ //集采供应商 if (StringUtils.equals("tqq9_sup_sh", name)) { DynamicObject tqq9_sup_bj = (DynamicObject) model.getValue("tqq9_sup_sh"); EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "supplier", tqq9_sup_bj, model); String tqq9_mulcombofield1 = tqq9_sup_bj.getString("tqq9_mulcombofield1"); - model.setValue("tqq9_suparea_sh",tqq9_mulcombofield1); + model.setValue("tqq9_suparea_sh", tqq9_mulcombofield1); view.updateView(); } //收货仓库 @@ -44,8 +47,168 @@ public class PurApplyBillPlugin extends AbstractBillPlugIn implements Plugin { entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "warehouse", tqq9_rewares_sh, model); view.updateView(); } - - - + //采购数量 + if (StringUtils.equals("applyqty", name)) { + BigDecimal applyqty = (BigDecimal) model.getValue("applyqty"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "applyqty", "tqq9_purqty_sh", model); + view.updateView(); + } + //应付金额 + if (StringUtils.equals("tqq9_yfje", name)) { + BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_sh", model); + view.updateView(); + } + //优惠金额_单头 + if (StringUtils.equals("tqq9_discountamt_sh", name)) { + BigDecimal tqq9_discountamt_sh = (BigDecimal) model.getValue("tqq9_discountamt_sh"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_sh, model); + view.updateView(); + } + //货返_单头 + if (StringUtils.equals("tqq9_hshfsyje_sh", name)) { + BigDecimal tqq9_hshfsyje_sh = (BigDecimal) model.getValue("tqq9_hshfsyje_sh"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_sh, model); + view.updateView(); + } + //现返_单头 + if (StringUtils.equals("tqq9_hsxfsyje_sh", name)) { + BigDecimal tqq9_hsxfsyje_sh = (BigDecimal) model.getValue("tqq9_hsxfsyje_sh"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_sh, model); + view.updateView(); + } + //--------------北京------------------ + //集采供应商 + if (StringUtils.equals("tqq9_sup_bj", name)) { + DynamicObject tqq9_sup_bj = (DynamicObject) model.getValue("tqq9_sup_bj"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "supplier", tqq9_sup_bj, model); + String tqq9_mulcombofield1 = tqq9_sup_bj.getString("tqq9_mulcombofield1"); + model.setValue("tqq9_suparea_bj", tqq9_mulcombofield1); + view.updateView(); + } + //收货仓库 + if (StringUtils.equals("tqq9_rewares_bj", name)) { + DynamicObject tqq9_rewares_bj = (DynamicObject) model.getValue("tqq9_rewares_bj"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "warehouse", tqq9_rewares_bj, model); + view.updateView(); + } + //采购数量 + if (StringUtils.equals("applyqty", name)) { + BigDecimal applyqty = (BigDecimal) model.getValue("applyqty"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "applyqty", "tqq9_purqty_bj", model); + view.updateView(); + } + //应付金额 + if (StringUtils.equals("tqq9_yfje", name)) { + BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_bj", model); + view.updateView(); + } + //优惠金额_单头 + if (StringUtils.equals("tqq9_discountamt_bj", name)) { + BigDecimal tqq9_discountamt_bj = (BigDecimal) model.getValue("tqq9_discountamt_bj"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_bj, model); + view.updateView(); + } + //货返_单头 + if (StringUtils.equals("tqq9_hshfsyje_bj", name)) { + BigDecimal tqq9_hshfsyje_bj = (BigDecimal) model.getValue("tqq9_hshfsyje_bj"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_bj, model); + view.updateView(); + } + //现返_单头 + if (StringUtils.equals("tqq9_hsxfsyje_bj", name)) { + BigDecimal tqq9_hsxfsyje_bj = (BigDecimal) model.getValue("tqq9_hsxfsyje_bj"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_bj, model); + view.updateView(); + } + //--------------广州------------------ + //集采供应商 + if (StringUtils.equals("tqq9_sup_gz", name)) { + DynamicObject tqq9_sup_gz = (DynamicObject) model.getValue("tqq9_sup_gz"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "supplier", tqq9_sup_gz, model); + String tqq9_mulcombofield1 = tqq9_sup_gz.getString("tqq9_mulcombofield1"); + model.setValue("tqq9_suparea_gz", tqq9_mulcombofield1); + view.updateView(); + } + //收货仓库 + if (StringUtils.equals("tqq9_rewares_gz", name)) { + DynamicObject tqq9_rewares_gz = (DynamicObject) model.getValue("tqq9_rewares_gz"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "warehouse", tqq9_rewares_gz, model); + view.updateView(); + } + //采购数量 + if (StringUtils.equals("applyqty", name)) { + BigDecimal applyqty = (BigDecimal) model.getValue("applyqty"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "applyqty", "tqq9_purqty_gz", model); + view.updateView(); + } + //应付金额 + if (StringUtils.equals("tqq9_yfje", name)) { + BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_gz", model); + view.updateView(); + } + //优惠金额_单头 + if (StringUtils.equals("tqq9_discountamt_gz", name)) { + BigDecimal tqq9_discountamt_gz = (BigDecimal) model.getValue("tqq9_discountamt_gz"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_gz, model); + view.updateView(); + } + //货返_单头 + if (StringUtils.equals("tqq9_hshfsyje_gz", name)) { + BigDecimal tqq9_hshfsyje_gz = (BigDecimal) model.getValue("tqq9_hshfsyje_gz"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_gz, model); + view.updateView(); + } + //现返_单头 + if (StringUtils.equals("tqq9_hsxfsyje_gz", name)) { + BigDecimal tqq9_hsxfsyje_gz = (BigDecimal) model.getValue("tqq9_hsxfsyje_gz"); + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_gz, model); + view.updateView(); + } + //分录优惠金额,现返,货返金额分摊 + if (StringUtils.equals("totalallamount", name)) { + EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher(); + BigDecimal tqq9_discountamt_sh = (BigDecimal) model.getValue("tqq9_discountamt_sh"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_sh, model); + BigDecimal tqq9_hshfsyje_sh = (BigDecimal) model.getValue("tqq9_hshfsyje_sh"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_sh, model); + BigDecimal tqq9_hsxfsyje_sh = (BigDecimal) model.getValue("tqq9_hsxfsyje_sh"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_sh, model); + BigDecimal tqq9_discountamt_bj = (BigDecimal) model.getValue("tqq9_discountamt_bj"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_bj, model); + BigDecimal tqq9_hshfsyje_bj = (BigDecimal) model.getValue("tqq9_hshfsyje_bj"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_bj, model); + BigDecimal tqq9_hsxfsyje_bj = (BigDecimal) model.getValue("tqq9_hsxfsyje_bj"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_bj, model); + BigDecimal tqq9_discountamt_gz = (BigDecimal) model.getValue("tqq9_discountamt_gz"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_gz, model); + BigDecimal tqq9_hshfsyje_gz = (BigDecimal) model.getValue("tqq9_hshfsyje_gz"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_gz, model); + BigDecimal tqq9_hsxfsyje_gz = (BigDecimal) model.getValue("tqq9_hsxfsyje_gz"); + entryFieldRefresher.updateAmountByOrg(SH_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_gz, model); + } } + + } \ No newline at end of file diff --git a/lc123/cloud/app/plugin/form/pm/PurSuggestRptFromPlugin.java b/lc123/cloud/app/plugin/form/pm/PurSuggestRptFromPlugin.java index 26b7120..458217d 100644 --- a/lc123/cloud/app/plugin/form/pm/PurSuggestRptFromPlugin.java +++ b/lc123/cloud/app/plugin/form/pm/PurSuggestRptFromPlugin.java @@ -224,6 +224,10 @@ public class PurSuggestRptFromPlugin extends AbstractFormPlugin implements Plugi "UNION ALL SELECT cInvCode, isum FROM SA_SalesOrderMaster_GZ ma (nolock) INNER JOIN SA_SalesOrderDetail_GZ de (nolock) ON ma.somid = de.somid WHERE DATEDIFF(MONTH, dInputDate, GETDATE()) BETWEEN 1 AND 3\n" + "AND cInvoiceTitle NOT LIKE '%广州励齿%'AND Status != '草稿' AND cInvCode NOT LIKE 'ZF%') AS combined GROUP BY cInvCode) AS a WHERE a.RowNum <= 2000 ORDER BY a.RowNum;"; + //已收货未上架数量 + String pendingsql = "/*dialect*/select '1' tqq9_isauto,t2.fmaterialid tqq9_purordermaterial,t1.forgid tqq9_org,sum(t2.fk_tqq9_dhsl) tqq9_pendingqty \n" + + "from t_pm_receiptnotice t1,t_pm_receiptnoticeentry t2 where t1.fid=t2.fid and fbillstatus='C' GROUP BY t2.fmaterialid,t1.forgid"; + DataSet goodspackagDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("sys"), goodspackagesql); DataSet realbalanceDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), realbalancesql); @@ -236,12 +240,15 @@ public class PurSuggestRptFromPlugin extends AbstractFormPlugin implements Plugi // DataSet range_bjDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("lc"), range_bj); // DataSet range_gzDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("lc"), range_gz); DataSet rangeDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("lc"), rangesql); + DataSet pendingSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), pendingsql); goodspackagDataSet = goodspackagDataSet.leftJoin(realbalanceDataSet).on("tqq9_material", "tqq9_material").on("tqq9_isauto", "tqq9_isauto").on("tqq9_org", "tqq9_org").select("tqq9_sku", "tqq9_org", "tqq9_isauto", "tqq9_material", "tqq9_sku_lc", "tqq9_purchaser", "tqq9_onsale", "tqq9_totalupstock", "tqq9_shinventory", "tqq9_bjinventory", "tqq9_gzinventory", "tqq9_cdinventory", "case when tqq9_org= " + sh + " then tqq9_shinventory when tqq9_org= " + bj + " then tqq9_bjinventory when tqq9_org= " + gz + " then tqq9_gzinventory when tqq9_org= " + cd + " then tqq9_cdinventory else 0 end tqq9_totalinventory").finish(); goodspackagDataSet = goodspackagDataSet.leftJoin(saloutbillDataSet).on("tqq9_sku", "tqq9_sku").on("tqq9_org", "tqq9_org").select("tqq9_sku", "tqq9_org", "tqq9_isauto", "tqq9_material", "tqq9_sku_lc", "tqq9_purchaser", "tqq9_onsale", "tqq9_totalupstock", "tqq9_shinventory", "tqq9_bjinventory", "tqq9_gzinventory", "tqq9_cdinventory", "tqq9_totalinventory", "tqq9_permonthsales_sh", "tqq9_permonthsales_bj", "tqq9_permonthsales_gz", "tqq9_permonthsales_cd", "tqq9_totalqty_sh", "tqq9_totalqty_bj", "tqq9_totalqty_gz", "tqq9_totalqty_cd").finish().addField("case when tqq9_org= " + sh + " then tqq9_totalqty_sh when tqq9_org= " + bj + " then tqq9_totalqty_bj when tqq9_org= " + gz + " then tqq9_totalqty_gz when tqq9_org= " + cd + " then tqq9_totalqty_cd else 0 end", "tqq9_totalqty").addField("case when tqq9_org= " + sh + " then tqq9_permonthsales_sh when tqq9_org= " + bj + " then tqq9_permonthsales_bj when tqq9_org= " + gz + " then tqq9_permonthsales_gz when tqq9_org= " + cd + " then tqq9_permonthsales_cd else 0 end", "tqq9_permonthsales"); purorderbillDataSet = purorderbillDataSet.leftJoin(materialpurchaseinfoDataSet).on("tqq9_purordermaterial", "tqq9_purordermaterial").select("tqq9_isauto", "tqq9_org", "tqq9_material", "tqq9_inventory_sh", "tqq9_inventory_bj", "tqq9_inventory_gz", "tqq9_inventory_cd").finish(); + pendingSet = pendingSet.leftJoin(materialpurchaseinfoDataSet).on("tqq9_purordermaterial", "tqq9_purordermaterial").select("tqq9_isauto", "tqq9_org", "tqq9_material", "tqq9_pendingqty").finish(); + goodspackagDataSet = goodspackagDataSet.leftJoin(purorderbillDataSet).on("tqq9_isauto", "tqq9_isauto").on("tqq9_org", "tqq9_org").on("tqq9_material", "tqq9_material").select("tqq9_sku", "tqq9_org", "tqq9_isauto", "tqq9_material", "tqq9_sku_lc", "tqq9_purchaser", "tqq9_onsale", "tqq9_totalupstock", "tqq9_shinventory", "tqq9_bjinventory", "tqq9_gzinventory", "tqq9_cdinventory", "tqq9_totalinventory", "tqq9_permonthsales_sh", "tqq9_permonthsales_bj", "tqq9_permonthsales_gz", "tqq9_permonthsales_cd", "tqq9_permonthsales", "tqq9_totalqty_sh", "tqq9_totalqty_bj", "tqq9_totalqty_gz", "tqq9_totalqty_cd", "tqq9_totalqty", "tqq9_inventory_sh", "tqq9_inventory_bj", "tqq9_inventory_gz", "tqq9_inventory_cd", "case when tqq9_org= " + sh + " and tqq9_shinventory <> 0 and tqq9_permonthsales_sh <> 0 then tqq9_shinventory/tqq9_permonthsales_sh else -1 end tqq9_shsaledates", "case when tqq9_org= " + bj + " and tqq9_bjinventory <> 0 and tqq9_permonthsales_bj <> 0 then tqq9_bjinventory/tqq9_permonthsales_bj else -1 end tqq9_bjsaledates", @@ -263,6 +270,11 @@ public class PurSuggestRptFromPlugin extends AbstractFormPlugin implements Plugi "tqq9_shsaledates", "tqq9_bjsaledates", "tqq9_gzsaledates", "tqq9_cdsaledates", "tqq9_saledates", "tqq9_remark", "tqq9_safeinventory", "tqq9_suppleinventory", "tqq9_onorderinventory_SH", "tqq9_onorderinventory_BJ", "tqq9_onorderinventory_GZ", "case when tqq9_org= " + sh + " then tqq9_onorderinventory_SH when tqq9_org= " + bj + " then tqq9_onorderinventory_BJ when tqq9_org= " + gz + " then tqq9_onorderinventory_GZ else 0 end tqq9_onorderinventory", "case when tqq9_shsaledates > 4.5 or tqq9_shsaledates = -1 then tqq9_shinventory else 0 end tqq9_slowinv_sh", "case when tqq9_bjsaledates > 4.5 or tqq9_bjsaledates = -1 then tqq9_bjinventory else 0 end tqq9_slowinv_bj", "case when tqq9_gzsaledates > 4.5 or tqq9_gzsaledates = -1 then tqq9_gzinventory else 0 end tqq9_slowinv_gz", "case when tqq9_cdsaledates > 4.5 or tqq9_cdsaledates = -1 then tqq9_cdinventory else 0 end tqq9_slowinv_cd", "tqq9_ranking").finish().addField("case when tqq9_onorderinventory <> 0 and tqq9_totalinventory <> 0 and tqq9_onorderinventory/tqq9_totalinventory>=0.8 then '需注意' else null end", "tqq9_onorderemark"); + goodspackagDataSet=goodspackagDataSet.leftJoin(pendingSet).on("tqq9_isauto", "tqq9_isauto").on("tqq9_org", "tqq9_org").on("tqq9_material", "tqq9_material").select("tqq9_sku", "tqq9_org", "tqq9_isauto", "tqq9_material", "tqq9_sku_lc", "tqq9_purchaser", "tqq9_onsale", "tqq9_totalupstock", "tqq9_shinventory", "tqq9_bjinventory", + "tqq9_gzinventory", "tqq9_cdinventory", "tqq9_totalinventory", "tqq9_permonthsales_sh", "tqq9_permonthsales_bj", "tqq9_permonthsales_gz", "tqq9_permonthsales_cd", "tqq9_permonthsales", "tqq9_totalqty_sh", "tqq9_totalqty_bj", "tqq9_totalqty_gz", "tqq9_totalqty_cd", "tqq9_totalqty", "tqq9_inventory_sh", "tqq9_inventory_bj", "tqq9_inventory_gz", "tqq9_inventory_cd", "tqq9_oninventory", + "tqq9_shsaledates", "tqq9_bjsaledates", "tqq9_gzsaledates", "tqq9_cdsaledates", "tqq9_saledates", "tqq9_remark", "tqq9_safeinventory", "tqq9_suppleinventory", "tqq9_onorderinventory_SH", "tqq9_onorderinventory_BJ", "tqq9_onorderinventory_GZ", "case when tqq9_org= " + sh + " then tqq9_onorderinventory_SH when tqq9_org= " + bj + " then tqq9_onorderinventory_BJ when tqq9_org= " + gz + " then tqq9_onorderinventory_GZ else 0 end tqq9_onorderinventory", + "case when tqq9_shsaledates > 4.5 or tqq9_shsaledates = -1 then tqq9_shinventory else 0 end tqq9_slowinv_sh", "case when tqq9_bjsaledates > 4.5 or tqq9_bjsaledates = -1 then tqq9_bjinventory else 0 end tqq9_slowinv_bj", + "case when tqq9_gzsaledates > 4.5 or tqq9_gzsaledates = -1 then tqq9_gzinventory else 0 end tqq9_slowinv_gz", "case when tqq9_cdsaledates > 4.5 or tqq9_cdsaledates = -1 then tqq9_cdinventory else 0 end tqq9_slowinv_cd", "tqq9_ranking","tqq9_onorderemark","tqq9_pendingqty").finish(); goodspackagDataSet = goodspackagDataSet.where("1=1" + ((!tqq9_queryorg.isEmpty()) ? " and tqq9_org in(" + orgBuilder.substring(1) + ")" : "") + ((!tqq9_querysku.isEmpty()) ? " and tqq9_sku in(" + skuBuilder.substring(1) + ")" : "")); @@ -312,6 +324,7 @@ public class PurSuggestRptFromPlugin extends AbstractFormPlugin implements Plugi entry.set("tqq9_inventory_cd", next.get("tqq9_inventory_cd"));//成都在途库存 entry.set("tqq9_oninventory", next.get("tqq9_oninventory"));//在途库存 entry.set("tqq9_suppleinventory", next.get("tqq9_suppleinventory"));//待补库存 + entry.set("tqq9_pendingqty", next.get("tqq9_pendingqty"));//待补库存 entry.set("tqq9_onorderinventory_SH", next.get("tqq9_onorderinventory_SH"));//上海占单库存 entry.set("tqq9_onorderinventory_BJ", next.get("tqq9_onorderinventory_BJ"));//北京占单库存 entry.set("tqq9_onorderinventory_GZ", next.get("tqq9_onorderinventory_GZ"));//广州占单库存 diff --git a/lc123/cloud/app/plugin/form/sys/RegistBillFactoryPlugin.java b/lc123/cloud/app/plugin/form/sys/RegistBillFactoryPlugin.java index f31e15c..5c84a08 100644 --- a/lc123/cloud/app/plugin/form/sys/RegistBillFactoryPlugin.java +++ b/lc123/cloud/app/plugin/form/sys/RegistBillFactoryPlugin.java @@ -116,7 +116,7 @@ public class RegistBillFactoryPlugin extends AbstractBillPlugIn { } } if(eSupIDSet.contains(tqq9_supplier.getLong("id"))){ - this.getView().showTipNotification("已经添加过改厂家,不需要重复添加!"); + this.getView().showTipNotification("已经添加过该厂家,不需要重复添加!"); }else{ DynamicObject entry = entries.addNew(); entry.set("tqq9_e_supplier", tqq9_supplier); diff --git a/lc123/cloud/app/plugin/utils/EntryFieldRefresher.java b/lc123/cloud/app/plugin/utils/EntryFieldRefresher.java index 014e4c5..defebc4 100644 --- a/lc123/cloud/app/plugin/utils/EntryFieldRefresher.java +++ b/lc123/cloud/app/plugin/utils/EntryFieldRefresher.java @@ -6,6 +6,9 @@ import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.datamodel.IDataModel; import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; public class EntryFieldRefresher { @@ -15,7 +18,7 @@ public class EntryFieldRefresher { * @param org 组织参数 * @param entityname 字段标识 * @param dynamicObject 基础资料 - * @param model 单据实体 + * @param model 单据实体 */ public void updateDynamicObjectByOrg(String org, String entityname, DynamicObject dynamicObject, IDataModel model) { @@ -29,15 +32,75 @@ public class EntryFieldRefresher { } } + + /** + * 处理组织和字段的工具类 + * + * @param org 组织参数 + * @param entityname 字段标识 + * @param sum_entityname 单头金额 + * @param model 单据实体 + */ + public void sumEntrByOrg(String org, String entityname, String sum_entityname, IDataModel model) { + + DynamicObjectCollection entries = model.getDataEntity(true).getDynamicObjectCollection("billentry"); + BigDecimal sum =BigDecimal.ZERO; + for (int i = 0; i < entries.size(); i++) { + DynamicObject entry = entries.get(i); + DynamicObject entryrecorg = entry.getDynamicObject("entryrecorg");//收货组织 + BigDecimal qty = entry.getBigDecimal(entityname);//分录字段值 + if (StringUtils.equals(org, entryrecorg.getString("number"))&&qty!=null) { + sum = sum.add(qty); + } + model.setValue(sum_entityname,sum); + } + } + /** * 处理组织和字段的工具类 * * @param org 组织参数 * @param entityname 字段标识 * @param amount 金额 - * @param model 单据实体 + * @param model 单据实体 */ public void updateAmountByOrg(String org, String entityname, BigDecimal amount, IDataModel model) { - // 这里可以根据需要添加实现逻辑 + if (amount.compareTo(BigDecimal.ZERO) > 0) { + DynamicObjectCollection entries = model.getDataEntity(true).getDynamicObjectCollection("billentry"); + if (entries != null && entries.size() > 0) { + BigDecimal remainRefundAmt = amount;//拆分后剩余的金额 + List seqs = new ArrayList<>(); + BigDecimal tqq9_totalamount = BigDecimal.ZERO; + for (int i = 0; i <= entries.size() - 1; i++) { + DynamicObject entry = entries.get(i); + DynamicObject entryrecorg = entry.getDynamicObject("entryrecorg");//收货组织 + if (StringUtils.equals(org, entryrecorg.getString("number"))) { + BigDecimal amountandtax = entry.getBigDecimal("amountandtax");//价税合计 + tqq9_totalamount = tqq9_totalamount.add(amountandtax); + if (amountandtax.compareTo(BigDecimal.ZERO) > 0) { + seqs.add(i); + } + } + } + for (int i = 0; i <= seqs.size() - 1; i++) { + int seq = seqs.get(i); + if (i == seqs.size() - 1) { + //如果是最后一行 + model.setValue(entityname, remainRefundAmt, seq);//明细金额 + } else { + //如果不是最后一行 + BigDecimal amountandtax = (BigDecimal) model.getValue("amountandtax", seq);//价税合计 + if (amountandtax.compareTo(BigDecimal.ZERO) == 0) { + model.setValue(entityname, BigDecimal.ZERO, seq);//明细金额 + } else { + BigDecimal tqq9_disamount = amount.multiply(amountandtax).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例 + model.setValue(entityname, tqq9_disamount, seq);//明细金额 + remainRefundAmt = remainRefundAmt.subtract(tqq9_disamount); + } + + } + } + } + } } }