183 lines
11 KiB
Java
183 lines
11 KiB
Java
package tqq9.lc123.cloud.app.plugin.form.pm;
|
|
|
|
import com.google.gson.Gson;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
import kd.bos.entity.datamodel.IDataModel;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.sdk.plugin.Plugin;
|
|
import tqq9.lc123.cloud.app.eip.iscb.LCLogService;
|
|
import tqq9.lc123.cloud.app.eip.iscb.impl.LCLogServiceImpl;
|
|
import tqq9.lc123.cloud.app.plugin.utils.EntryFieldRefresher;
|
|
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
|
|
|
import java.io.IOException;
|
|
import java.math.BigDecimal;
|
|
import java.util.ArrayList;
|
|
import java.util.EventObject;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 采购审申请单复制实时查询三地的供应商返利信息
|
|
*/
|
|
public class PurApplyCopyBillPlugin extends AbstractFormPlugin implements Plugin {
|
|
private static String URL;
|
|
private static String FLXT_TOKEN;
|
|
private final static String SH_ORGNUMBER = "SHLC";
|
|
|
|
private final static String BJ_ORGNUMBER = "BJLC";
|
|
|
|
private final static String GZ_ORGNUMBER = "GZLC";
|
|
|
|
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;
|
|
// 申请单
|
|
DynamicObject token = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
new QFilter[]{new QFilter("number", QCP.equals, "FLXT_TOKEN")});
|
|
FLXT_TOKEN = token != null ? token.getString("name") : null;
|
|
}
|
|
|
|
@Override
|
|
public void afterCopyData(EventObject e) {
|
|
super.afterCopyData(e);
|
|
IDataModel model = this.getModel();
|
|
LCLogService lcLogService = new LCLogServiceImpl();
|
|
HashMap<String, String> tokenMap = new HashMap<String, String>();
|
|
tokenMap.put("Authorization", FLXT_TOKEN);
|
|
DynamicObject tqq9_sup_gz = (DynamicObject) model.getValue("tqq9_sup_gz");
|
|
|
|
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, "0.0")) {
|
|
//货返
|
|
model.setValue("tqq9_hshfzje_gz", totalMoney);//含税货返总金额
|
|
model.setValue("tqq9_hshfkyje_gz", totalMoneyAvailable);//含税货返可用金额
|
|
} else if (StringUtils.equals(type, "1.0")) {
|
|
//现返
|
|
model.setValue("tqq9_hsxfzje_gz", totalMoney);//含税现返总金额
|
|
model.setValue("tqq9_hsxfkyje_gz", totalMoneyAvailable);//含税现返可用金额
|
|
}
|
|
}
|
|
lcLogService.savelog("查询返利金额", URL, false, true, queryMap.toString(), bodyString);
|
|
}
|
|
} catch (IOException ex) {
|
|
lcLogService.savelog("创建返利规则", URL, false, false, queryMap.toString(), "接口调用报错,无返回值");
|
|
throw new RuntimeException(ex + ",请求返利系统失败");
|
|
}
|
|
}
|
|
DynamicObject tqq9_sup_bj = (DynamicObject) model.getValue("tqq9_sup_bj");
|
|
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, "0.0")) {
|
|
//货返
|
|
model.setValue("tqq9_hshfzje_bj", totalMoney);//含税货返总金额
|
|
model.setValue("tqq9_hshfkyje_bj", totalMoneyAvailable);//含税货返可用金额
|
|
} else if (StringUtils.equals(type, "1.0")) {
|
|
//现返
|
|
model.setValue("tqq9_hsxfzje_bj", totalMoney);//含税现返总金额
|
|
model.setValue("tqq9_hsxfkyje_bj", totalMoneyAvailable);//含税现返可用金额
|
|
}
|
|
}
|
|
lcLogService.savelog("查询返利金额", URL, false, true, queryMap.toString(), bodyString);
|
|
}
|
|
} catch (IOException ex) {
|
|
lcLogService.savelog("创建返利规则", URL, false, false, queryMap.toString(), "接口调用报错,无返回值");
|
|
throw new RuntimeException(ex + ",请求返利系统失败");
|
|
}
|
|
}
|
|
DynamicObject tqq9_sup_sh = (DynamicObject) model.getValue("tqq9_sup_sh");//供应商
|
|
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, "0.0")) {
|
|
//货返
|
|
model.setValue("tqq9_hshfzje_sh", totalMoney);//含税货返总金额
|
|
model.setValue("tqq9_hshfkyje_sh", totalMoneyAvailable);//含税货返可用金额
|
|
} else if (StringUtils.equals(type, "1.0")) {
|
|
//现返
|
|
model.setValue("tqq9_hsxfzje_sh", totalMoney);//含税现返总金额
|
|
model.setValue("tqq9_hsxfkyje_sh", totalMoneyAvailable);//含税现返可用金额
|
|
}
|
|
}
|
|
lcLogService.savelog("查询返利金额", URL, false, true, queryMap.toString(), bodyString);
|
|
}
|
|
} catch (IOException ex) {
|
|
lcLogService.savelog("创建返利规则", URL, false, false, queryMap.toString(), "接口调用报错,无返回值");
|
|
throw new RuntimeException(ex + ",请求返利系统失败");
|
|
}
|
|
}
|
|
}
|
|
|
|
} |