2025-08-29 10:01:57 +00:00
|
|
|
package tqq9.lc123.cloud.app.plugin.form.pm;
|
|
|
|
|
|
2025-09-16 08:05:06 +00:00
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2025-09-10 10:16:39 +00:00
|
|
|
import com.google.gson.Gson;
|
2025-08-29 10:01:57 +00:00
|
|
|
import kd.bos.bill.AbstractBillPlugIn;
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
2025-09-10 10:16:39 +00:00
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
2025-08-29 10:01:57 +00:00
|
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
|
|
|
import kd.bos.entity.datamodel.IDataModel;
|
2025-09-10 10:16:39 +00:00
|
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
2025-08-29 10:01:57 +00:00
|
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
2025-09-16 08:05:06 +00:00
|
|
|
import kd.bos.form.FormShowParameter;
|
2025-08-29 10:01:57 +00:00
|
|
|
import kd.bos.form.IFormView;
|
2025-09-10 10:16:39 +00:00
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
2025-09-16 08:05:06 +00:00
|
|
|
import kd.bos.servicehelper.user.UserServiceHelper;
|
2025-08-29 10:01:57 +00:00
|
|
|
import kd.sdk.plugin.Plugin;
|
|
|
|
|
import tqq9.lc123.cloud.app.plugin.utils.EntryFieldRefresher;
|
2025-09-13 09:42:55 +00:00
|
|
|
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
2025-09-01 08:50:23 +00:00
|
|
|
import java.math.BigDecimal;
|
2025-09-16 08:05:06 +00:00
|
|
|
import java.util.*;
|
2025-09-01 08:50:23 +00:00
|
|
|
|
2025-08-29 10:01:57 +00:00
|
|
|
/**
|
|
|
|
|
* 单据界面插件
|
|
|
|
|
*/
|
|
|
|
|
public class PurApplyBillPlugin extends AbstractBillPlugIn implements Plugin {
|
2025-09-10 10:16:39 +00:00
|
|
|
private static String URL;
|
2025-09-16 08:05:06 +00:00
|
|
|
private static DynamicObject BILLTYPE;
|
|
|
|
|
private static DynamicObject BIZTYPE;
|
|
|
|
|
private static DynamicObject LINETYPE;
|
2025-10-18 09:51:13 +00:00
|
|
|
private static String FLXT_TOKEN;
|
2025-09-13 09:42:55 +00:00
|
|
|
|
2025-09-10 10:16:39 +00:00
|
|
|
static {
|
|
|
|
|
DynamicObject url = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, "FLXT_Balance_Url")});
|
|
|
|
|
URL = url != null ? url.getString("name") : null;
|
2025-09-16 08:05:06 +00:00
|
|
|
// 申请单
|
|
|
|
|
DynamicObject billtype = BusinessDataServiceHelper.loadSingle("bos_billtype", new QFilter[]{new QFilter("number", QCP.equals, "pm_PurApplyBill_STD_BT_S")});
|
|
|
|
|
BILLTYPE = billtype;
|
|
|
|
|
DynamicObject biztype = BusinessDataServiceHelper.loadSingle("bd_biztype", new QFilter[]{new QFilter("number", QCP.equals, "110")});
|
|
|
|
|
BIZTYPE = biztype;
|
|
|
|
|
DynamicObject linetype = BusinessDataServiceHelper.loadSingle("bd_linetype", new QFilter[]{new QFilter("number", QCP.equals, "010")});
|
|
|
|
|
LINETYPE = linetype;
|
2025-10-18 09:51:13 +00:00
|
|
|
DynamicObject token = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, "FLXT_TOKEN")});
|
|
|
|
|
FLXT_TOKEN = token != null ? token.getString("name") : null;
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
2025-09-13 09:42:55 +00:00
|
|
|
|
2025-09-10 10:16:39 +00:00
|
|
|
private final static String ENTRYENTITY = "billentry";
|
|
|
|
|
|
2025-08-29 10:01:57 +00:00
|
|
|
private final static String SH_ORGNUMBER = "SHLC";
|
|
|
|
|
|
|
|
|
|
private final static String BJ_ORGNUMBER = "BJLC";
|
|
|
|
|
|
|
|
|
|
private final static String GZ_ORGNUMBER = "GZLC";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void propertyChanged(PropertyChangedArgs e) {
|
|
|
|
|
super.propertyChanged(e);
|
|
|
|
|
String name = e.getProperty().getName();
|
|
|
|
|
DynamicObject dataEntity = this.getModel().getDataEntity(true);
|
|
|
|
|
IDataModel model = this.getModel();
|
|
|
|
|
IFormView view = this.getView();
|
2025-10-18 09:51:13 +00:00
|
|
|
HashMap<String, String> tokenMap = new HashMap<String, String>();
|
|
|
|
|
tokenMap.put("Authorization", FLXT_TOKEN);
|
2025-09-01 08:50:23 +00:00
|
|
|
//--------------上海------------------
|
2025-08-29 10:01:57 +00:00
|
|
|
//集采供应商
|
|
|
|
|
if (StringUtils.equals("tqq9_sup_sh", name)) {
|
2025-10-18 09:51:13 +00:00
|
|
|
|
2025-09-10 10:16:39 +00:00
|
|
|
DynamicObject tqq9_sup_sh = (DynamicObject) model.getValue("tqq9_sup_sh");//供应商
|
2025-10-17 09:48:44 +00:00
|
|
|
if (tqq9_sup_sh != null) {
|
|
|
|
|
DynamicObject org = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("number", QCP.equals, SH_ORGNUMBER)});
|
|
|
|
|
String number = org.getString("number");
|
|
|
|
|
DynamicObject org_fl = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, number)});
|
|
|
|
|
String orgid_fl = org_fl != null ? org_fl.getString("name") : null;
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
|
|
|
|
entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "supplier", tqq9_sup_sh, model);
|
|
|
|
|
String tqq9_mulcombofield1 = tqq9_sup_sh.getString("tqq9_mulcombofield1");
|
|
|
|
|
model.setValue("tqq9_suparea_sh", tqq9_mulcombofield1);
|
|
|
|
|
HashMap<String, Object> queryMap = new HashMap<>();
|
|
|
|
|
queryMap.put("supplierId", tqq9_sup_sh.getString("tqq9_ztsupplierid"));
|
|
|
|
|
queryMap.put("companyId", orgid_fl);
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
try {
|
|
|
|
|
String bodyString = HttpRequestUtils.doGet(URL, queryMap, tokenMap);
|
|
|
|
|
HashMap map = gson.fromJson(bodyString, HashMap.class);
|
|
|
|
|
ArrayList<Map<String, Object>> data = (ArrayList) map.get("data");
|
|
|
|
|
if (data != null) {
|
|
|
|
|
for (Map datum : data) {
|
|
|
|
|
Map<String, Object> dataMap = datum;
|
|
|
|
|
String type = dataMap.get("type").toString();//类型
|
|
|
|
|
BigDecimal totalMoney = new BigDecimal((Double) dataMap.get("totalMoney"));//剩余总金额
|
|
|
|
|
BigDecimal totalMoneyAvailable = new BigDecimal((Double) dataMap.get("totalMoneyAvailable"));//可使用金额
|
|
|
|
|
if (StringUtils.equals(type, "1.0")) {
|
|
|
|
|
//货返
|
|
|
|
|
model.setValue("tqq9_hshfzje_sh", totalMoney);//含税货返总金额
|
|
|
|
|
model.setValue("tqq9_hshfkyje_sh", totalMoneyAvailable);//含税货返可用金额
|
|
|
|
|
} else if (StringUtils.equals(type, "0.0")) {
|
|
|
|
|
//现返
|
|
|
|
|
model.setValue("tqq9_hsxfzje_sh", totalMoney);//含税现返总金额
|
|
|
|
|
model.setValue("tqq9_hsxfkyje_sh", totalMoneyAvailable);//含税现返可用金额
|
|
|
|
|
}
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-17 09:48:44 +00:00
|
|
|
} catch (IOException ex) {
|
|
|
|
|
throw new RuntimeException(ex);
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
2025-08-29 10:01:57 +00:00
|
|
|
}
|
|
|
|
|
//收货仓库
|
2025-10-30 07:47:33 +00:00
|
|
|
if (StringUtils.equals("tqq9_rewares_sh", name)) {
|
|
|
|
|
DynamicObject tqq9_rewares_sh = (DynamicObject) model.getValue("tqq9_rewares_sh");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
|
|
|
|
entryFieldRefresher.updateDynamicObjectByOrg(SH_ORGNUMBER, "warehouse", tqq9_rewares_sh, model);
|
|
|
|
|
view.updateView();
|
|
|
|
|
}
|
2025-10-29 06:37:00 +00:00
|
|
|
// //采购数量
|
2025-09-01 08:50:23 +00:00
|
|
|
if (StringUtils.equals("applyqty", name)) {
|
|
|
|
|
BigDecimal applyqty = (BigDecimal) model.getValue("applyqty");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
|
|
|
|
entryFieldRefresher.sumEntrByOrg(SH_ORGNUMBER, "applyqty", "tqq9_purqty_sh", model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//应付金额
|
|
|
|
|
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);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//优惠金额_单头
|
|
|
|
|
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);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//货返_单头
|
|
|
|
|
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);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//现返_单头
|
|
|
|
|
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);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//--------------北京------------------
|
|
|
|
|
//集采供应商
|
|
|
|
|
if (StringUtils.equals("tqq9_sup_bj", name)) {
|
|
|
|
|
DynamicObject tqq9_sup_bj = (DynamicObject) model.getValue("tqq9_sup_bj");
|
2025-10-17 09:48:44 +00:00
|
|
|
if (tqq9_sup_bj != null) {
|
|
|
|
|
DynamicObject org = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("number", QCP.equals, BJ_ORGNUMBER)});
|
|
|
|
|
String number = org.getString("number");
|
|
|
|
|
DynamicObject org_fl = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, number)});
|
|
|
|
|
String orgid_fl = org_fl != null ? org_fl.getString("name") : null;
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
|
|
|
|
entryFieldRefresher.updateDynamicObjectByOrg(BJ_ORGNUMBER, "supplier", tqq9_sup_bj, model);
|
|
|
|
|
String tqq9_mulcombofield1 = tqq9_sup_bj.getString("tqq9_mulcombofield1");
|
|
|
|
|
model.setValue("tqq9_suparea_bj", tqq9_mulcombofield1);
|
|
|
|
|
HashMap<String, Object> queryMap = new HashMap<>();
|
|
|
|
|
queryMap.put("supplierId", tqq9_sup_bj.getString("tqq9_ztsupplierid"));
|
|
|
|
|
queryMap.put("companyId", orgid_fl);
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
try {
|
|
|
|
|
String bodyString = HttpRequestUtils.doGet(URL, queryMap, tokenMap);
|
|
|
|
|
HashMap map = gson.fromJson(bodyString, HashMap.class);
|
|
|
|
|
ArrayList<Map<String, Object>> data = (ArrayList) map.get("data");
|
|
|
|
|
if (data != null) {
|
|
|
|
|
for (Map datum : data) {
|
|
|
|
|
Map<String, Object> dataMap = datum;
|
|
|
|
|
String type = dataMap.get("type").toString();//类型
|
|
|
|
|
BigDecimal totalMoney = new BigDecimal((Double) dataMap.get("totalMoney"));//剩余总金额
|
|
|
|
|
BigDecimal totalMoneyAvailable = new BigDecimal((Double) dataMap.get("totalMoneyAvailable"));//可使用金额
|
|
|
|
|
if (StringUtils.equals(type, "1.0")) {
|
|
|
|
|
//货返
|
|
|
|
|
model.setValue("tqq9_hshfzje_bj", totalMoney);//含税货返总金额
|
|
|
|
|
model.setValue("tqq9_hshfkyje_bj", totalMoneyAvailable);//含税货返可用金额
|
|
|
|
|
} else if (StringUtils.equals(type, "0.0")) {
|
|
|
|
|
//现返
|
|
|
|
|
model.setValue("tqq9_hsxfzje_bj", totalMoney);//含税现返总金额
|
|
|
|
|
model.setValue("tqq9_hsxfkyje_bj", totalMoneyAvailable);//含税现返可用金额
|
|
|
|
|
}
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-17 09:48:44 +00:00
|
|
|
} catch (IOException ex) {
|
|
|
|
|
throw new RuntimeException(ex);
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-10-17 09:48:44 +00:00
|
|
|
}
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//收货仓库
|
|
|
|
|
if (StringUtils.equals("tqq9_rewares_bj", name)) {
|
|
|
|
|
DynamicObject tqq9_rewares_bj = (DynamicObject) model.getValue("tqq9_rewares_bj");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateDynamicObjectByOrg(BJ_ORGNUMBER, "warehouse", tqq9_rewares_bj, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//采购数量
|
|
|
|
|
if (StringUtils.equals("applyqty", name)) {
|
|
|
|
|
BigDecimal applyqty = (BigDecimal) model.getValue("applyqty");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.sumEntrByOrg(BJ_ORGNUMBER, "applyqty", "tqq9_purqty_bj", model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//应付金额
|
|
|
|
|
if (StringUtils.equals("tqq9_yfje", name)) {
|
|
|
|
|
BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.sumEntrByOrg(BJ_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_bj", model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//优惠金额_单头
|
|
|
|
|
if (StringUtils.equals("tqq9_discountamt_bj", name)) {
|
|
|
|
|
BigDecimal tqq9_discountamt_bj = (BigDecimal) model.getValue("tqq9_discountamt_bj");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_bj, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//货返_单头
|
|
|
|
|
if (StringUtils.equals("tqq9_hshfsyje_bj", name)) {
|
|
|
|
|
BigDecimal tqq9_hshfsyje_bj = (BigDecimal) model.getValue("tqq9_hshfsyje_bj");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_bj, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//现返_单头
|
|
|
|
|
if (StringUtils.equals("tqq9_hsxfsyje_bj", name)) {
|
|
|
|
|
BigDecimal tqq9_hsxfsyje_bj = (BigDecimal) model.getValue("tqq9_hsxfsyje_bj");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_bj, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//--------------广州------------------
|
|
|
|
|
//集采供应商
|
|
|
|
|
if (StringUtils.equals("tqq9_sup_gz", name)) {
|
|
|
|
|
DynamicObject tqq9_sup_gz = (DynamicObject) model.getValue("tqq9_sup_gz");
|
2025-10-17 09:48:44 +00:00
|
|
|
if (tqq9_sup_gz != null) {
|
|
|
|
|
|
|
|
|
|
DynamicObject org = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("number", QCP.equals, GZ_ORGNUMBER)});
|
|
|
|
|
String number = org.getString("number");
|
|
|
|
|
DynamicObject org_fl = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, number)});
|
|
|
|
|
String orgid_fl = org_fl != null ? org_fl.getString("name") : null;
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
|
|
|
|
entryFieldRefresher.updateDynamicObjectByOrg(GZ_ORGNUMBER, "supplier", tqq9_sup_gz, model);
|
|
|
|
|
String tqq9_mulcombofield1 = tqq9_sup_gz.getString("tqq9_mulcombofield1");
|
|
|
|
|
model.setValue("tqq9_suparea_gz", tqq9_mulcombofield1);
|
|
|
|
|
HashMap<String, Object> queryMap = new HashMap<>();
|
|
|
|
|
queryMap.put("supplierId", tqq9_sup_gz.getString("tqq9_ztsupplierid"));
|
|
|
|
|
queryMap.put("companyId", orgid_fl);
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
try {
|
|
|
|
|
String bodyString = HttpRequestUtils.doGet(URL, queryMap, tokenMap);
|
|
|
|
|
HashMap map = gson.fromJson(bodyString, HashMap.class);
|
|
|
|
|
ArrayList<Map<String, Object>> data = (ArrayList) map.get("data");
|
|
|
|
|
if (data != null) {
|
|
|
|
|
for (Map datum : data) {
|
|
|
|
|
Map<String, Object> dataMap = datum;
|
|
|
|
|
String type = dataMap.get("type").toString();//类型
|
|
|
|
|
BigDecimal totalMoney = new BigDecimal((Double) dataMap.get("totalMoney"));//剩余总金额
|
|
|
|
|
BigDecimal totalMoneyAvailable = new BigDecimal((Double) dataMap.get("totalMoneyAvailable"));//可使用金额
|
|
|
|
|
if (StringUtils.equals(type, "1.0")) {
|
|
|
|
|
//货返
|
|
|
|
|
model.setValue("tqq9_hshfzje_gz", totalMoney);//含税货返总金额
|
|
|
|
|
model.setValue("tqq9_hshfkyje_gz", totalMoneyAvailable);//含税货返可用金额
|
|
|
|
|
} else if (StringUtils.equals(type, "0.0")) {
|
|
|
|
|
//现返
|
|
|
|
|
model.setValue("tqq9_hsxfzje_gz", totalMoney);//含税现返总金额
|
|
|
|
|
model.setValue("tqq9_hsxfkyje_gz", totalMoneyAvailable);//含税现返可用金额
|
|
|
|
|
}
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-17 09:48:44 +00:00
|
|
|
} catch (IOException ex) {
|
|
|
|
|
throw new RuntimeException(ex);
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-10 10:16:39 +00:00
|
|
|
}
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//收货仓库
|
|
|
|
|
if (StringUtils.equals("tqq9_rewares_gz", name)) {
|
|
|
|
|
DynamicObject tqq9_rewares_gz = (DynamicObject) model.getValue("tqq9_rewares_gz");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateDynamicObjectByOrg(GZ_ORGNUMBER, "warehouse", tqq9_rewares_gz, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//采购数量
|
|
|
|
|
if (StringUtils.equals("applyqty", name)) {
|
|
|
|
|
BigDecimal applyqty = (BigDecimal) model.getValue("applyqty");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.sumEntrByOrg(GZ_ORGNUMBER, "applyqty", "tqq9_purqty_gz", model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//应付金额
|
|
|
|
|
if (StringUtils.equals("tqq9_yfje", name)) {
|
|
|
|
|
BigDecimal tqq9_yfje = (BigDecimal) model.getValue("tqq9_yfje");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.sumEntrByOrg(GZ_ORGNUMBER, "tqq9_yfje", "tqq9_payamount_gz", model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//优惠金额_单头
|
|
|
|
|
if (StringUtils.equals("tqq9_discountamt_gz", name)) {
|
|
|
|
|
BigDecimal tqq9_discountamt_gz = (BigDecimal) model.getValue("tqq9_discountamt_gz");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_gz, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//货返_单头
|
|
|
|
|
if (StringUtils.equals("tqq9_hshfsyje_gz", name)) {
|
|
|
|
|
BigDecimal tqq9_hshfsyje_gz = (BigDecimal) model.getValue("tqq9_hshfsyje_gz");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_gz, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//现返_单头
|
|
|
|
|
if (StringUtils.equals("tqq9_hsxfsyje_gz", name)) {
|
|
|
|
|
BigDecimal tqq9_hsxfsyje_gz = (BigDecimal) model.getValue("tqq9_hsxfsyje_gz");
|
|
|
|
|
EntryFieldRefresher entryFieldRefresher = new EntryFieldRefresher();
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_gz, model);
|
2025-10-29 06:37:00 +00:00
|
|
|
// view.updateView();
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
|
|
|
|
//分录优惠金额,现返,货返金额分摊
|
2025-09-03 09:49:27 +00:00
|
|
|
if (StringUtils.equals("tqq9_amount", name)) {
|
2025-09-01 08:50:23 +00:00
|
|
|
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");
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_bj, model);
|
2025-09-01 08:50:23 +00:00
|
|
|
BigDecimal tqq9_hshfsyje_bj = (BigDecimal) model.getValue("tqq9_hshfsyje_bj");
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_bj, model);
|
2025-09-01 08:50:23 +00:00
|
|
|
BigDecimal tqq9_hsxfsyje_bj = (BigDecimal) model.getValue("tqq9_hsxfsyje_bj");
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(BJ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_bj, model);
|
2025-09-01 08:50:23 +00:00
|
|
|
BigDecimal tqq9_discountamt_gz = (BigDecimal) model.getValue("tqq9_discountamt_gz");
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_disamount", tqq9_discountamt_gz, model);
|
2025-09-01 08:50:23 +00:00
|
|
|
BigDecimal tqq9_hshfsyje_gz = (BigDecimal) model.getValue("tqq9_hshfsyje_gz");
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_hfamount", tqq9_hshfsyje_gz, model);
|
2025-09-01 08:50:23 +00:00
|
|
|
BigDecimal tqq9_hsxfsyje_gz = (BigDecimal) model.getValue("tqq9_hsxfsyje_gz");
|
2025-09-03 09:49:27 +00:00
|
|
|
entryFieldRefresher.updateAmountByOrg(GZ_ORGNUMBER, "tqq9_xfamount", tqq9_hsxfsyje_gz, model);
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
2025-09-10 10:16:39 +00:00
|
|
|
//物料带出最高限价
|
|
|
|
|
if (StringUtils.equals("material", name)) {
|
|
|
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
|
|
|
int rowIndex = changeData.getRowIndex();
|
|
|
|
|
DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection(ENTRYENTITY);
|
|
|
|
|
DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex);
|
|
|
|
|
DynamicObject material = dynamicObject.getDynamicObject("material");
|
|
|
|
|
DynamicObject masterid = material.getDynamicObject("masterid");
|
|
|
|
|
DynamicObject bd_material = BusinessDataServiceHelper.loadSingle(masterid.getLong("id"), "bd_material");
|
2025-09-13 09:42:55 +00:00
|
|
|
DynamicObject org = (DynamicObject) this.getModel().getValue("entryrecorg", rowIndex);
|
2025-09-10 10:16:39 +00:00
|
|
|
//上海
|
|
|
|
|
if (StringUtils.equals(SH_ORGNUMBER, org.getString("number"))) {
|
|
|
|
|
BigDecimal tqq9_maxprice_sh = bd_material.getBigDecimal("tqq9_maxprice_sh");
|
|
|
|
|
if (tqq9_maxprice_sh.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
getModel().setValue("priceandtax", tqq9_maxprice_sh, rowIndex);
|
|
|
|
|
getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_sh, rowIndex);
|
|
|
|
|
}
|
|
|
|
|
//北京
|
|
|
|
|
} else if (StringUtils.equals(BJ_ORGNUMBER, org.getString("number"))) {
|
|
|
|
|
BigDecimal tqq9_maxprice_bj = bd_material.getBigDecimal("tqq9_maxprice_bj");
|
|
|
|
|
if (tqq9_maxprice_bj.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
getModel().setValue("priceandtax", tqq9_maxprice_bj, rowIndex);
|
|
|
|
|
getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_bj, rowIndex);
|
|
|
|
|
}
|
|
|
|
|
//广州
|
|
|
|
|
} else if (StringUtils.equals(GZ_ORGNUMBER, org.getString("number"))) {
|
|
|
|
|
BigDecimal tqq9_maxprice_gz = bd_material.getBigDecimal("tqq9_maxprice_gz");
|
|
|
|
|
if (tqq9_maxprice_gz.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
getModel().setValue("priceandtax", tqq9_maxprice_gz, rowIndex);
|
|
|
|
|
getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_gz, rowIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//校验含税单价和最高限价
|
|
|
|
|
if (StringUtils.equals("priceandtax", name)) {
|
|
|
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
|
|
|
int rowIndex = changeData.getRowIndex();
|
|
|
|
|
int seq = rowIndex;
|
|
|
|
|
BigDecimal newValue = (BigDecimal) changeData.getNewValue();
|
2025-09-13 09:42:55 +00:00
|
|
|
BigDecimal tqq9_zgcgxj = (BigDecimal) getModel().getValue("tqq9_zgcgxj", seq);
|
2025-09-10 10:16:39 +00:00
|
|
|
if (newValue.compareTo(tqq9_zgcgxj) > 0 && tqq9_zgcgxj.compareTo(BigDecimal.ZERO) > 0) {
|
2025-09-13 09:42:55 +00:00
|
|
|
getModel().setValue("priceandtax", 0, seq);
|
2025-09-10 10:16:39 +00:00
|
|
|
this.getView().showErrorNotification("物料明细分录行" + seq + "含税单价超过最高采购限价,请修改");
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-01 08:50:23 +00:00
|
|
|
}
|
2025-08-29 10:01:57 +00:00
|
|
|
|
2025-09-16 08:05:06 +00:00
|
|
|
@Override
|
|
|
|
|
public void afterCreateNewData(EventObject e) {
|
|
|
|
|
super.afterCreateNewData(e);
|
|
|
|
|
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
|
|
|
|
|
JSONObject tqq9_pursuggestrpt = (JSONObject) formShowParameter.getCustomParam("pm_purapplybill");
|
|
|
|
|
if (tqq9_pursuggestrpt != null) {
|
|
|
|
|
IDataModel model = this.getModel();
|
|
|
|
|
DynamicObjectCollection billentry = model.getDataEntity(true).getDynamicObjectCollection("billentry");
|
|
|
|
|
billentry.clear();
|
|
|
|
|
//采购建议报表
|
|
|
|
|
JSONArray tqq9_pursuggestrptentry = tqq9_pursuggestrpt.getJSONArray("tqq9_pursuggestrptentry");
|
2025-08-29 10:01:57 +00:00
|
|
|
|
2025-09-16 08:05:06 +00:00
|
|
|
long currentUserId = UserServiceHelper.getCurrentUserId();
|
|
|
|
|
DynamicObject user = BusinessDataServiceHelper.loadSingle("bos_user", new QFilter[]{new QFilter("id", QCP.equals, currentUserId)});
|
|
|
|
|
DynamicObjectCollection entryentity = user.getDynamicObjectCollection("entryentity");
|
|
|
|
|
DynamicObject dept = null;//部门
|
|
|
|
|
for (DynamicObject dynamicObject : entryentity) {
|
|
|
|
|
boolean ispartjob = dynamicObject.getBoolean("ispartjob");
|
|
|
|
|
if (!ispartjob) {
|
|
|
|
|
dept = dynamicObject.getDynamicObject("dpt");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DynamicObject LCJT = BusinessDataServiceHelper.loadSingle("bos_org", new QFilter[]{new QFilter("name", QCP.equals, "励齿集团")});
|
|
|
|
|
|
|
|
|
|
DynamicObject currency = BusinessDataServiceHelper.loadSingle("bd_currency",
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, "CNY")});//币别
|
|
|
|
|
DynamicObject taxrate = BusinessDataServiceHelper.loadSingle("bd_taxrate",
|
|
|
|
|
new QFilter[]{new QFilter("number", QCP.equals, "V13")});//税率
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (Object dynamicObject : tqq9_pursuggestrptentry) {
|
|
|
|
|
JSONObject entry = (JSONObject) dynamicObject;
|
|
|
|
|
if (entry.getBoolean("tqq9_ischange")) {
|
|
|
|
|
billentry.addNew();
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
model.setValue("org", LCJT);//申请组织
|
|
|
|
|
model.setValue("dept", dept);//申请部门
|
|
|
|
|
model.setValue("bizuser", user);//申请人
|
|
|
|
|
model.setValue("currency", currency);//币别
|
|
|
|
|
model.setValue("creator", user);//创建人
|
|
|
|
|
model.setValue("lastupdateuser", user);//修改人
|
|
|
|
|
model.setValue("lastupdatetime", date);//修改时间
|
|
|
|
|
model.setValue("billtype", BILLTYPE);//单据类型
|
|
|
|
|
model.setValue("biztype", BIZTYPE);//业务类型
|
|
|
|
|
model.setValue("biztime", date);//申请日期
|
|
|
|
|
model.setValue("billstatus", "A");//单据状态
|
|
|
|
|
model.setValue("closestatus", "A");//关闭状态
|
|
|
|
|
model.setValue("cancelstatus", "A");//作废状态
|
|
|
|
|
model.setValue("changestatus", "A");//变更状态
|
|
|
|
|
model.setValue("subversion", "1");//子版本号
|
|
|
|
|
model.setValue("version", "1");//版本号
|
|
|
|
|
model.setValue("tqq9_sfsyhf_sh", "false");//是否使用货返
|
|
|
|
|
model.setValue("tqq9_hshfsysl_sh", taxrate);//含税货返使用税率
|
|
|
|
|
model.setValue("tqq9_sfsyxf_sh", "false");//是否使用现返
|
|
|
|
|
model.setValue("tqq9_hsxfsysl_sh", taxrate);//含税现返使用税率
|
|
|
|
|
model.setValue("tqq9_sfsyhf_bj", "false");//是否使用货返
|
|
|
|
|
model.setValue("tqq9_hshfsysl_bj", taxrate);//含税货返使用税率
|
|
|
|
|
model.setValue("tqq9_sfsyxf_bj", "false");//是否使用现返
|
|
|
|
|
model.setValue("tqq9_hsxfsysl_bj", taxrate);//含税现返使用税率
|
|
|
|
|
model.setValue("tqq9_sfsyhf_gz", "false");//是否使用货返
|
|
|
|
|
model.setValue("tqq9_hshfsysl_gz", taxrate);//含税货返使用税率
|
|
|
|
|
model.setValue("tqq9_sfsyxf_gz", "false");//是否使用现返
|
|
|
|
|
model.setValue("tqq9_hsxfsysl_gz", taxrate);//含税现返使用税率
|
|
|
|
|
}
|
|
|
|
|
JSONObject org = entry.getJSONObject("tqq9_org");
|
|
|
|
|
DynamicObject tqq9_org = BusinessDataServiceHelper.loadSingle(org.getLong("id"), "bos_org");//组织
|
|
|
|
|
JSONObject material = entry.getJSONObject("tqq9_material");//物料
|
|
|
|
|
DynamicObject tqq9_material = BusinessDataServiceHelper.loadSingle(material.getLong("id"), "bd_material");//物料
|
|
|
|
|
DynamicObject materialpurchaseinfo = BusinessDataServiceHelper.loadSingle("bd_materialpurchaseinfo", new QFilter[]{new QFilter("masterid", QCP.equals, tqq9_material.getLong("id"))});//物料采购信息
|
|
|
|
|
BigDecimal tqq9_saledates = entry.getBigDecimal("tqq9_saledates");
|
|
|
|
|
model.setValue("material", materialpurchaseinfo, i);//物料
|
|
|
|
|
model.setValue("materialname", tqq9_material.getString("name"), i);//物料名称
|
|
|
|
|
model.setValue("unit", tqq9_material.getDynamicObject("baseunit"), i);//计量单位
|
|
|
|
|
model.setValue("baseunit", tqq9_material.getDynamicObject("baseunit"), i);//基本单位
|
2025-10-22 10:13:53 +00:00
|
|
|
model.setValue("rowclosestatus", "A",i);//行关闭状态
|
|
|
|
|
model.setValue("rowterminatestatus", "A",i);//行终止状态
|
2025-09-16 08:05:06 +00:00
|
|
|
model.setValue("entryrecorg", tqq9_org, i);//收货组织
|
|
|
|
|
model.setValue("entryreqorg", tqq9_org, i);//需求组织
|
|
|
|
|
model.setValue("entryreqdept", dept, i);//需求部门
|
|
|
|
|
model.setValue("reqdate", date, i);//需求日期
|
|
|
|
|
model.setValue("purdate", date, i);//建议采购日期
|
|
|
|
|
model.setValue("deliverdate", date, i);//交货日期
|
|
|
|
|
model.setValue("bomtime", date, i);//展BOM时间
|
|
|
|
|
model.setValue("linetype", LINETYPE, i);//行类型
|
|
|
|
|
model.setValue("linetype", LINETYPE, i);//行类型
|
2025-10-17 09:48:44 +00:00
|
|
|
model.setValue("entrychangetype", "B", i);//变更方式
|
2025-09-16 08:05:06 +00:00
|
|
|
model.setValue("entrycreator", user, i);//创建人
|
|
|
|
|
model.setValue("entryrecdept", tqq9_org, i);//收货部门
|
|
|
|
|
model.setValue("entrypurdept", tqq9_org, i);//采购部门
|
|
|
|
|
model.setValue("entryoperatorgroup", tqq9_org, i);//采购组
|
|
|
|
|
model.setValue("tqq9_expectsaletime", tqq9_saledates, i);//预计销售时间(月)
|
|
|
|
|
if (StringUtils.equals(tqq9_org.getString("number"), "SHLC")) {
|
|
|
|
|
model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_sh"), i);//最高采购限价
|
|
|
|
|
model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_sh"), i);//含税单价
|
|
|
|
|
} else if (StringUtils.equals(tqq9_org.getString("number"), "BJLC")) {
|
|
|
|
|
model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_bj"), i);//最高采购限价
|
|
|
|
|
model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_bj"), i);//含税单价
|
|
|
|
|
} else if (StringUtils.equals(tqq9_org.getString("number"), "GZLC")) {
|
|
|
|
|
model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_gz"), i);//最高采购限价
|
|
|
|
|
model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_gz"), i);//含税单价
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-29 10:01:57 +00:00
|
|
|
}
|