1.跟单任务控制台-配件,总需求现有逻辑是合同已审核数量减去调拨已审核数量,需要再减去其他领料审核的数量,再减去跟单任务控制台上的取消数量
This commit is contained in:
25655 2025-03-19 14:51:19 +08:00
parent 3590bcdb35
commit 902ffd9b94

View File

@ -38,6 +38,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
@ -229,12 +230,13 @@ public class tracktaskconsoleFormPlugIn extends AbstractBillPlugIn implements Be
DynamicObject materialEntry = materialEntries.get(i); DynamicObject materialEntry = materialEntries.get(i);
String materialNum = materialEntry.getString("yem_materiel.number"); String materialNum = materialEntry.getString("yem_materiel.number");
long materialNumid = materialEntry.getLong("yem_materiel.id"); long materialNumid = materialEntry.getLong("yem_materiel.id");
BigDecimal yemCancelNum = materialEntry.getBigDecimal("yem_cancel_num");
//已采购 //已采购
BigDecimal yem_buyfromcmmp = getbuyfromcmmp(materialNum, yem_bd_products); BigDecimal yem_buyfromcmmp = getbuyfromcmmp(materialNum, yem_bd_products);
model.setValue("yem_buyfromcmmp", yem_buyfromcmmp, i); model.setValue("yem_buyfromcmmp", yem_buyfromcmmp, i);
//储备 //储备
DynamicObjectCollection yem_accreserveapply = QueryServiceHelper.query("yem_accreserveapply", "yem_detailinfo.yem_qty", new QFilter[]{new QFilter("yem_detailinfo.yem_materiel.id", QCP.equals, materialNumid), new QFilter("status", QCP.equals, "C")}, "yem_audittime desc", 1); DynamicObjectCollection yem_accreserveapply = QueryServiceHelper.query("yem_accreserveapply", "yem_detailinfo.yem_qty", new QFilter[]{new QFilter("yem_detailinfo.yem_materiel.id", QCP.equals, materialNumid), new QFilter("status", QCP.equals, "C")}, "yem_audittime desc", 1);
if (yem_accreserveapply != null && yem_accreserveapply.size() > 0) { if (yem_accreserveapply != null && !yem_accreserveapply.isEmpty()) {
model.setValue("yem_accreserveqty", yem_accreserveapply.get(0).getBigDecimal("yem_detailinfo.yem_qty"), i); model.setValue("yem_accreserveqty", yem_accreserveapply.get(0).getBigDecimal("yem_detailinfo.yem_qty"), i);
} }
//VMI-eas数量+CMMP数量 //VMI-eas数量+CMMP数量
@ -254,7 +256,10 @@ public class tracktaskconsoleFormPlugIn extends AbstractBillPlugIn implements Be
BigDecimal cmmpyem_gmpjqty = getSumCMMPQty(materialNum, "D", yem_bd_products); BigDecimal cmmpyem_gmpjqty = getSumCMMPQty(materialNum, "D", yem_bd_products);
model.setValue("yem_gmpjqty", easyem_gmpjqty.add(cmmpyem_gmpjqty), i); model.setValue("yem_gmpjqty", easyem_gmpjqty.add(cmmpyem_gmpjqty), i);
BigDecimal tolreqqty = gettolreqqty(yem_bd_products, materialNumid); BigDecimal tolreqqty = gettolreqqty(yem_bd_products, materialNumid);
model.setValue("yem_tolreqqty", tolreqqty, i); BigDecimal yemEsDelivernoticeqty = getDelivernoticeqty(yem_bd_products, materialNumid);
BigDecimal yem_tolreqqty = tolreqqty.subtract(yemEsDelivernoticeqty);
yem_tolreqqty = yem_tolreqqty.subtract(yemCancelNum);
model.setValue("yem_tolreqqty", yem_tolreqqty, i);
//处理库存差 //处理库存差
BigDecimal yem_qtysub = easyem_gmpjqty.add(cmmpyem_gmpjqty).add(yem_buyfromcmmp).subtract(tolreqqty); BigDecimal yem_qtysub = easyem_gmpjqty.add(cmmpyem_gmpjqty).add(yem_buyfromcmmp).subtract(tolreqqty);
model.setValue("yem_qtysub", yem_qtysub, i); model.setValue("yem_qtysub", yem_qtysub, i);
@ -281,8 +286,43 @@ public class tracktaskconsoleFormPlugIn extends AbstractBillPlugIn implements Be
} }
} }
/**
* 获取销售出库其他出库的已审核数量汇总数据
*
* @param yem_bd_products 产品分类
*
* @param materialNumid 物料编码
*
* @return 数量汇总值
*
*/
@NotNull
private static BigDecimal getDelivernoticeqty(DynamicObject yem_bd_products, long materialNumid) {
List<Long> productId = getProductId(yem_bd_products);
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");
qFilter.and("yem_billtype.number", QCP.equals, "yem_es_delivernotice_o");
qFilter.and("yem_es_materialinfo.yem_materiel.id", QCP.equals, materialNumid);
qFilter.and("yem_bd_products.id", QCP.in, productId);
DynamicObject[] yemEsDelivernotice = BusinessDataServiceHelper.load("yem_es_delivernotice", "id,billno" +
",yem_es_materialinfo,yem_es_materialinfo.yem_qty,yem_es_materialinfo.yem_materiel,billstatus,yem_billtype,yem_bd_products"
, new QFilter[]{qFilter});
BigDecimal yemEsDelivernoticeqty = BigDecimal.ZERO;
for (DynamicObject dynamicObject : yemEsDelivernotice) {
DynamicObjectCollection yemEsMaterialinfo1 = dynamicObject.getDynamicObjectCollection("yem_es_materialinfo");
for (DynamicObject object : yemEsMaterialinfo1) {
long aLong = object.getLong("yem_materiel.id");
BigDecimal yemQty = object.getBigDecimal("yem_qty");
if (aLong == materialNumid) {
yemEsDelivernoticeqty = yemQty.add(yemEsDelivernoticeqty);
}
}
}
return yemEsDelivernoticeqty;
}
/** /**
* 账龄赋值 * 账龄赋值
*
* @param i * @param i
* @param number * @param number
* @param dynamicObject * @param dynamicObject