采购订单携带合同明细 校验订货数量
This commit is contained in:
parent
3fb91020e7
commit
a8123adecc
|
@ -105,7 +105,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadList
|
|||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs args) {
|
||||
super.afterDoOperation(args);
|
||||
//todo 开头结尾根据(项目名称和计量单位都有值的记录行,导入系统中;)---序号属于数字的
|
||||
// 开头结尾根据(项目名称和计量单位都有值的记录行,导入系统中;)---序号属于数字的
|
||||
// 重复点击时覆盖明细列表数据(先删除再新增)----提示先删除行
|
||||
// 删除附件时 情况汇总明细和清单明细 https://developer.kingdee.com/article/132124949988215296?productLineId=29&lang=zh-CN
|
||||
// 删行时 同步删除明细
|
||||
|
@ -122,6 +122,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadList
|
|||
//合同清单汇总分录
|
||||
DynamicObjectCollection qeug_invoiceentryinfo = this.getView().getModel().getEntryEntity("qeug_invoiceentryinfo");
|
||||
|
||||
//todo:提示确认框
|
||||
//如果已经有数据,先删除再新增
|
||||
if (!qeug_invoiceentryinfo.isEmpty()) {
|
||||
deleteList();
|
||||
|
@ -185,7 +186,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadList
|
|||
}
|
||||
|
||||
//合同明细清单 qeug_contractsummarylist
|
||||
//todo 存合同id,sheet名字
|
||||
// 存合同id,sheet名字
|
||||
DynamicObject contractsummarylist = BusinessDataServiceHelper.newDynamicObject("qeug_contractsummarylist");
|
||||
contractsummarylist.set("enable","1");//使用状态
|
||||
contractsummarylist.set("status","A");//数据状态
|
||||
|
|
|
@ -16,8 +16,13 @@ import kd.bos.form.plugin.AbstractFormPlugin;
|
|||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 采购订单
|
||||
|
@ -34,6 +39,10 @@ public class RepeOrderFormPlugin extends AbstractFormPlugin {
|
|||
super.propertyChanged(e);
|
||||
String propertyname = e.getProperty().getName();
|
||||
switch (propertyname) {
|
||||
//todo:
|
||||
// 在选合同时,查询当前合同所有订单当前明细行的本次订货数量和,将剩余数量算出带到订单(仅作参考,因为当前订单操作时,可能又新增了别的订单导致剩余数量不准确)
|
||||
// 在订单提交校验时,查询当前合同所有订单当前明细行的数量,超过合同数量时校验
|
||||
|
||||
//采购合同(外)
|
||||
case "cqcontract":
|
||||
// String contractname = (String)this.getModel().getDataEntity(true).get("contractname");//suppliercontact supplier cqcontract
|
||||
|
@ -53,17 +62,31 @@ public class RepeOrderFormPlugin extends AbstractFormPlugin {
|
|||
DynamicObject recon_contractbill = BusinessDataServiceHelper.loadSingle("recon_contractbill", new QFilter[]{q1,q2});
|
||||
|
||||
if (null != recon_contractbill) {
|
||||
|
||||
//查询当前合同所有相关订单
|
||||
QFilter q3 = new QFilter("cqcontract.number", QCP.equals, recon_contractbill.getString("billno"));
|
||||
QFilter q4 = new QFilter("cqcontract.name", QCP.equals, recon_contractbill.getString("billname"));
|
||||
DynamicObject[] repeOrderforms = BusinessDataServiceHelper.load("repe_orderform",
|
||||
"id,cqcontract.number,cqcontract.name,cqcontract,orderformentry," +
|
||||
"orderformentry.ordercount,orderformentry.contractnum", new QFilter[]{q3, q4});
|
||||
|
||||
//携带明细
|
||||
int j = 0;
|
||||
DynamicObjectCollection qeugOrderformentrys = recon_contractbill.getDynamicObjectCollection("qeug_orderformentry");
|
||||
for (DynamicObject qeugOrderformentry : qeugOrderformentrys) {
|
||||
int row1 = this.getModel().insertEntryRow("orderformentry", j);
|
||||
DynamicObject object = qeugOrderformentrys.get(row1);
|
||||
object.set("seq", row1);
|
||||
//通过行号获取--订货数量总和
|
||||
BigDecimal ordercount = getOrderCount(repeOrderforms, row1);
|
||||
BigDecimal qeugContractnum =(BigDecimal) qeugOrderformentry.get("qeug_contractnum");//合同数量
|
||||
BigDecimal contractremainnum = qeugContractnum.subtract(ordercount);//剩余订货数量 = 合同数量 - 总订货数量
|
||||
this.getModel().setValue("material", qeugOrderformentry.get("qeug_material"), row1);//物料编码
|
||||
this.getModel().setValue("brand", qeugOrderformentry.get("qeug_brand"), row1);//品牌
|
||||
this.getModel().setValue("model", qeugOrderformentry.get("qeug_model"), row1);//型号
|
||||
this.getModel().setValue("contractnum", qeugOrderformentry.get("qeug_contractnum"), row1);//合同数量
|
||||
this.getModel().setValue("contractremainnum", qeugOrderformentry.get("qeug_contractremainnum"), row1);//合同剩余数量
|
||||
this.getModel().setValue("contractremainnum", contractremainnum, row1);//合同剩余数量
|
||||
this.getModel().setValue("qeug_contractremainnum", contractremainnum, row1);//合同剩余数量
|
||||
this.getModel().setValue("ordercount", qeugOrderformentry.get("qeug_ordercount"), row1);//本次订货数量
|
||||
this.getModel().setValue("entryenterdate", qeugOrderformentry.get("qeug_entryenterdate"), row1);//要求进场日期
|
||||
this.getModel().setValue("unitprice", qeugOrderformentry.get("qeug_unitprice"), row1);//材料单价
|
||||
|
@ -94,4 +117,19 @@ public class RepeOrderFormPlugin extends AbstractFormPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 某一行,订货数量总和
|
||||
*/
|
||||
@NotNull
|
||||
public static BigDecimal getOrderCount(DynamicObject[] repeOrderforms, int row1) {
|
||||
BigDecimal ordercount = BigDecimal.ZERO;//订货数量
|
||||
for (int i = 0; i < repeOrderforms.length; i++) {
|
||||
DynamicObject repeOrderform = repeOrderforms[i];
|
||||
DynamicObjectCollection orderformentry = repeOrderform.getDynamicObjectCollection("orderformentry");
|
||||
DynamicObject dynamicObject = orderformentry.get(row1);
|
||||
ordercount = ordercount.add(dynamicObject.getBigDecimal("ordercount"));
|
||||
}
|
||||
return ordercount;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package shkd.repc.repe.opplugin;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
|
||||
import static shkd.repc.repe.formplugin.RepeOrderFormPlugin.getOrderCount;
|
||||
|
||||
public class RepeOrderSubmitOPPlugin extends AbstractOperationServicePlugIn {
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
e.addValidator(new AbstractValidator() {
|
||||
@Override
|
||||
public void validate() {
|
||||
String operateKey = this.getOperateKey();
|
||||
ExtendedDataEntity[] dataEntities1 = this.getDataEntities();
|
||||
switch (operateKey) {
|
||||
case "save":
|
||||
case "submit":
|
||||
// 在订单提交校验时,查询当前合同所有订单当前明细行的数量,超过合同数量时校验
|
||||
for (int i = 0; i < dataEntities1.length; i++) {
|
||||
//
|
||||
DynamicObject dataEntity = dataEntities1[i].getDataEntity();
|
||||
DynamicObjectCollection orderformentrys = dataEntity.getDynamicObjectCollection("orderformentry");
|
||||
|
||||
for (int j = 0; j < orderformentrys.size(); j++) {
|
||||
DynamicObject dy = orderformentrys.get(j);
|
||||
|
||||
String number = "";
|
||||
String name = "";
|
||||
DynamicObject cqcontract = dataEntity.getDynamicObject("cqcontract");
|
||||
if (null != cqcontract) {
|
||||
number = cqcontract.getString("number");
|
||||
name = cqcontract.getString("name");
|
||||
}
|
||||
QFilter q1 = new QFilter("billno", QCP.equals, number);
|
||||
QFilter q2 = new QFilter("billname", QCP.equals, name);
|
||||
DynamicObject recon_contractbill = BusinessDataServiceHelper.loadSingle("recon_contractbill", new QFilter[]{q1,q2});
|
||||
|
||||
if (null != recon_contractbill) {
|
||||
|
||||
//查询当前合同所有相关订单
|
||||
QFilter q3 = new QFilter("cqcontract.number", QCP.equals, recon_contractbill.getString("billno"));
|
||||
QFilter q4 = new QFilter("cqcontract.name", QCP.equals, recon_contractbill.getString("billname"));
|
||||
DynamicObject[] repeOrderforms = BusinessDataServiceHelper.load("repe_orderform",
|
||||
"id,cqcontract.number,cqcontract.name,cqcontract,orderformentry," +
|
||||
"orderformentry.ordercount,orderformentry.contractnum", new QFilter[]{q3, q4});
|
||||
|
||||
//通过行号获取--订货数量总和
|
||||
BigDecimal ordercount = getOrderCount(repeOrderforms, j);//订货数量总和
|
||||
BigDecimal contractnum =(BigDecimal) dy.get("contractnum");//合同数量
|
||||
BigDecimal contractremainnum = contractnum.subtract(ordercount);//剩余订货数量 = 合同数量 - 总订货数量
|
||||
BigDecimal ordercounts = dy.getBigDecimal("ordercount");//本次订货数量
|
||||
|
||||
int result = ordercounts.compareTo(contractremainnum);
|
||||
if (result > 0) {
|
||||
this.addErrorMessage(dataEntities1[i], "订单明细第" + (j + 1) + "行 本次订货数量 不能大于 合同剩余数量");
|
||||
System.out.println("num1 < num2");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import kd.bos.util.StringUtils;
|
|||
import shkd.repc.recon.opplugin.TestOPPlugin;
|
||||
import shkd.utils.OAUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -36,15 +37,16 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
public void afterExecuteOperationTransaction(AfterOperationArgs e){
|
||||
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
|
||||
//todo:定时任务推送所有供应商 变更审核操作之后推送供应商
|
||||
String operationKey = e.getOperationKey();
|
||||
if ("pushoasupplier".equals(operationKey)) {
|
||||
if ("audit".equals(operationKey)) {
|
||||
|
||||
for (DynamicObject dataEntity : e.getDataEntities()) {
|
||||
//String url = System.getProperty("efms.infcompany.url.ip");
|
||||
//logger.info("url");
|
||||
//获取token
|
||||
String oaToken = OAUtils.getOaToken();
|
||||
// String oaToken = OAUtils.getOaToken();
|
||||
String oaToken = "OAUtils.getOaToken()";
|
||||
|
||||
if (StringUtils.isNotEmpty(oaToken)) {
|
||||
//ICS新增/更新OA客户租户接口
|
||||
|
@ -62,6 +64,13 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
String customerPostjson = null;
|
||||
try {
|
||||
customerPostjson = HttpClientUtils.postjson(customerUrl, customerHeader, customerBody.toJSONString());
|
||||
JSONObject jsonObject = JSONObject.parseObject(customerPostjson);
|
||||
if (!jsonObject.isEmpty()) {
|
||||
String result = (String) JSONObject.parseObject(customerPostjson).get("success");
|
||||
if ("success".equals(result)) {
|
||||
// logger.info("ICS新增/更新OA客户租户接口返回结果:\n{}", customerPostjson);
|
||||
}
|
||||
}
|
||||
logger.info("ICS新增/更新OA客户租户接口返回结果:\n{}", customerPostjson);
|
||||
} catch (Exception ex) {
|
||||
logger.info(String.format("ICS新增/更新OA客户租户接口异常:%s", ex.getMessage()));
|
||||
|
@ -81,8 +90,8 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
private static JSONObject assembleBody(long supplierID){
|
||||
JSONObject customerBody = null;
|
||||
//获取正式供应商
|
||||
// QFilter q = new QFilter("id", QCP.equals, supplierID);
|
||||
QFilter q = new QFilter("number", QCP.equals, "111");//成都筑垒建筑工程有限公司
|
||||
QFilter q = new QFilter("id", QCP.equals, supplierID);
|
||||
// QFilter q = new QFilter("number", QCP.equals, "111");//成都筑垒建筑工程有限公司
|
||||
DynamicObject official_supplier = BusinessDataServiceHelper.loadSingle(RESM_OFFICIAL_SUPPLIER, new QFilter[]{q});
|
||||
if (null != official_supplier) {
|
||||
|
||||
|
@ -93,6 +102,8 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
String legalbody = official_supplier.getString("artificialperson");
|
||||
Date createTime = official_supplier.getDate("createtime");
|
||||
Date updateTime = official_supplier.getDate("modifytime");
|
||||
Object createtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
|
||||
Object updatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(updateTime);
|
||||
|
||||
//接口请求体
|
||||
customerBody = new JSONObject();
|
||||
|
@ -104,8 +115,8 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
customerBody.put("enablestate", "2");//"客户状态:默认2",
|
||||
customerBody.put("pk_custclass", "02");//"客户基本分类:默认02",
|
||||
customerBody.put("legalbody", legalbody);// "法人",
|
||||
customerBody.put("createTime", createTime);// "创建时间:例如2024-06-02 17:27:10",
|
||||
customerBody.put("updateTime", updateTime);//"更新时间:例如2024-06-02 17:27:10",
|
||||
customerBody.put("createTime", createtime);// "创建时间:例如2024-06-02 17:27:10",
|
||||
customerBody.put("updateTime", updatetime);//"更新时间:例如2024-06-02 17:27:10",
|
||||
customerBody.put("def1", "租赁客户");//"客商类别:默认租赁客户",
|
||||
JSONArray custBankaccMapBody = new JSONArray();
|
||||
|
||||
|
@ -139,6 +150,17 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
}
|
||||
custBankaccMapBody.add(custBankaccBody);
|
||||
}
|
||||
//无银行信息
|
||||
if (entry_banks.isEmpty()) {
|
||||
JSONObject custBankaccBody = new JSONObject();
|
||||
custBankaccBody.put("accnum","");//"银行账号",
|
||||
custBankaccBody.put("pk_bankdoc", "");// "开户行名称:例如招商银行股份有限公司上海分行外高桥支行龙江支行"
|
||||
custBankaccBody.put("city","");//"城市"
|
||||
custBankaccBody.put("accname","");//"银行账号名称",
|
||||
custBankaccBody.put("pk_banktype", "");//todo:"银行类别:例如招商银行",
|
||||
custBankaccBody.put("psnOrCompany", "3397730183813155472");// "个人或公司:公司:3397730183813155472/个人:-7676950454987503991"
|
||||
custBankaccMapBody.add(custBankaccBody);
|
||||
}
|
||||
customerBody.put("bankacc", custBankaccMapBody);
|
||||
}
|
||||
return customerBody;
|
||||
|
|
Loading…
Reference in New Issue