a
This commit is contained in:
@@ -47,27 +47,9 @@ namespace GZ.LJY000.Biori.SAL_OUTSTOCK
|
||||
var rows = result.ReturnData as DynamicObjectCollection;
|
||||
if (rows.Any())
|
||||
{
|
||||
//var parentRows = rows.Where(w => !w["FParentRowId"].ToString().IsNullOrEmpty());
|
||||
//var subRows = rows.Where(w => w["FParentRowId"].ToString().IsNullOrEmpty());
|
||||
foreach (var item in entity)
|
||||
{
|
||||
DynamicObject row = null;
|
||||
//var parentRowId = item["ParentRowId"].ToString();
|
||||
//var rowId = item["RowId"].ToString();
|
||||
|
||||
//if (parentRowId.IsNullOrEmpty())
|
||||
//{
|
||||
// //var row = rows.FirstOrDefault(w => w["FRowId"].ToString() == item["RowId"].ToString());
|
||||
// row = parentRows.FirstOrDefault(w => w["FMaterialID_Id"].Long2Int() == item["MaterialID_Id"].Long2Int());
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var parentMatId = item["ParentMatId_Id"].Long2Int();
|
||||
// var parentRow = parentRows.FirstOrDefault(w => w["FMaterialID_Id"].Long2Int() == parentMatId);
|
||||
// row = subRows.FirstOrDefault(w => w["FParentRowId"].ToString() == parentRow["FRowId"].ToString() && w["FMaterialID_Id"] == item["MaterialID_Id"]);
|
||||
//}
|
||||
|
||||
row = rows.FirstOrDefault(w => w["FMaterialID_Id"].Long2Int() == item["MaterialID_Id"].Long2Int());
|
||||
DynamicObject row = rows.FirstOrDefault(w => w["FPackBillNo"].IsNullOrEmpty() && w["FMaterialID_Id"].Long2Int() == item["MaterialID_Id"].Long2Int());
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
|
||||
@@ -22,9 +22,10 @@ namespace GZ.LJY000.Biori.SAL_OUTSTOCK
|
||||
|
||||
e.FieldKeys.Add("FRowType");
|
||||
e.FieldKeys.Add("FPackBillNo");
|
||||
e.FieldKeys.Add("FPackBillSeq");
|
||||
e.FieldKeys.Add("FPackBillEntryId");
|
||||
//e.FieldKeys.Add("FPackBillSeq");
|
||||
//e.FieldKeys.Add("FPackBillEntryId");
|
||||
e.FieldKeys.Add("FRealQty");
|
||||
e.FieldKeys.Add("FPackBarCode");
|
||||
}
|
||||
|
||||
public override void OnAddValidators(AddValidatorsEventArgs e)
|
||||
@@ -33,12 +34,58 @@ namespace GZ.LJY000.Biori.SAL_OUTSTOCK
|
||||
//添加检查校验器:
|
||||
if (this.FormOperation.OperationId == 1)
|
||||
{
|
||||
var validator = new VaildatorEventPlugInEx();//新增的校验器
|
||||
validator.EntityKey = "FEntity";
|
||||
e.Validators.Add(validator);//添加校验器
|
||||
//var validator = new VaildatorEventPlugInEx();//新增的校验器
|
||||
//validator.EntityKey = "FEntity";
|
||||
//e.Validators.Add(validator);//添加校验器
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sqlL"></param>
|
||||
/// <returns></returns>
|
||||
private DynamicObjectCollection DoGetPackInfo(List<string> sqlL)
|
||||
{
|
||||
var sqlUnion = string.Join(" UNION ALL ", sqlL);
|
||||
var sql = $@"/*dialect*/
|
||||
|
||||
WITH #基础数据 AS (
|
||||
{sqlUnion}
|
||||
)
|
||||
SELECT tt.*,t0.FBARCODE,t0.FBILLNO,t0.FBILLID,t0.FBILLENTRYID,t0.FBILLSEQ,t0.FBILLFORMID
|
||||
,t1.*,t2.FNUMERATOR,t2.FDENOMINATOR
|
||||
FROM #基础数据 tt
|
||||
INNER JOIN T_UNW_WMS_BARCODE t0 on t0.FBARCODE = tt.PackBarCode
|
||||
CROSS APPLY (
|
||||
SELECT t1.FBILLNO,t1e.FEntryID,t1e.FSeq,t1e.FQTY,t1e.FGZLQTY,t1e.FZGSQTY,t1e.FUNITID,t1e.FFYLQTY,t1.FBOMID,t1e.FMATERIALID
|
||||
,t1.FQTY AS 'MainQty'
|
||||
FROM T_PRD_PACKAGEINSTOCK t1
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t1e on t1.FID = t1e.FID
|
||||
WHERE t1.FSRCBILLENTRYID = t0.FBILLENTRYID
|
||||
AND t1e.FMATERIALID = tt.MaterialId
|
||||
AND tt.FRowType = t1e.FPRODUCTTYPE
|
||||
UNION ALL
|
||||
SELECT t1.FBILLNO,0 FEntryID,0,t1.FQTY,0,0,0,t1.FFYLQTY,t1.FBOMID,t1.FMATERIALID
|
||||
,t1.FQTY AS 'MainQty'
|
||||
FROM T_PRD_PACKAGEINSTOCK t1
|
||||
WHERE t1.FSRCBILLENTRYID = t0.FBILLENTRYID
|
||||
AND t1.FMATERIALID = tt.MaterialId
|
||||
AND tt.FRowType = t1.FPRODUCTTYPE
|
||||
) t1
|
||||
LEFT JOIN T_ENG_BOMCHILD t2 on t2.FID = t1.FBOMID AND t1.FMATERIALID = t2.FMATERIALID
|
||||
ORDER BY tt.EntrySeq
|
||||
|
||||
";
|
||||
|
||||
var res = DBUtils.ExecuteDynamicObject(this.Context, sql);
|
||||
if (res != null && res.Count > 0)
|
||||
return res;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public override void EndOperationTransaction(EndOperationTransactionArgs e)
|
||||
{
|
||||
base.EndOperationTransaction(e);
|
||||
@@ -75,12 +122,67 @@ namespace GZ.LJY000.Biori.SAL_OUTSTOCK
|
||||
}
|
||||
}
|
||||
|
||||
if (isInStock)
|
||||
DoComputePackgeInStockQty(sqlL);
|
||||
else
|
||||
DoComputePackgeOutStockQty(sqlL);
|
||||
//if (isInStock)
|
||||
// DoComputePackgeInStockQty(sqlL);
|
||||
//else
|
||||
// DoComputePackgeOutStockQty(sqlL);
|
||||
|
||||
DoComputePackgeQty(sqlL, !isInStock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 入库操作
|
||||
/// </summary>
|
||||
/// <param name="sqlL"></param>
|
||||
private void DoComputePackgeQty(List<string> sqlL, bool isOutStock)
|
||||
{
|
||||
if (sqlL.Any())
|
||||
{
|
||||
var minus = isOutStock ? -1 : 1;
|
||||
|
||||
var updSqlL = $@"/*dialect*/
|
||||
|
||||
WITH #基础数据 AS (
|
||||
{string.Join(" UNION ALL ", sqlL)}
|
||||
)
|
||||
UPDATE t0 SET t0.FQTY = t0.FQTY + (t1.QTY * {minus})
|
||||
,t0.FOUTSTOCKQTY = t0.FOUTSTOCKQTY - (t1.QTY * {minus})
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
INNER JOIN #基础数据 t1 on t1.FBILLNO = t0.FBILLNO
|
||||
WHERE 1 = 1
|
||||
AND t0.FDOCUMENTSTATUS = 'C'
|
||||
|
||||
";
|
||||
|
||||
//更新组装单信
|
||||
var resData = DBUtils.Execute(this.Context, updSqlL);
|
||||
if (resData > 0)
|
||||
{
|
||||
updSqlL = $@"/*dialect*/
|
||||
WITH #基础数据 AS (
|
||||
{string.Join(" UNION ALL ", sqlL)}
|
||||
)
|
||||
UPDATE t0e SET t0e.FQTY = t0e.FQTY + (t0e.FQTY / t3.FQTY * (t1.QTY * {minus} / t2.FDENOMINATOR * t2.FNUMERATOR))
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN #基础数据 t1 on t1.FBILLNO = t0.FBILLNO
|
||||
INNER JOIN T_ENG_BOMCHILD t2 on t2.FID = t0.FBOMID AND t2.FMATERIALID = t0e.FMATERIALID
|
||||
CROSS APPLY (
|
||||
SELECT SUM(t3e.FQTY) FQTY
|
||||
FROM T_PRD_PACKAGEINSTOCKENTRY t3e
|
||||
WHERE t3e.FID = t0e.FID AND t3e.FMATERIALID = t0e.FMATERIALID
|
||||
GROUP BY t3e.FID,t3e.FMATERIALID
|
||||
) t3
|
||||
WHERE 1 = 1
|
||||
AND t0.FDOCUMENTSTATUS = 'C'
|
||||
";
|
||||
var res = DBUtils.Execute(this.Context, updSqlL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 入库操作
|
||||
/// </summary>
|
||||
@@ -105,6 +207,22 @@ WHERE 1 = 1
|
||||
|
||||
//更新组装单信
|
||||
var resData = DBUtils.Execute(this.Context, updSqlL);
|
||||
if (resData > 0)
|
||||
{
|
||||
updSqlL = $@"/*dialect*/
|
||||
WITH #基础数据 AS (
|
||||
{string.Join(" UNION ALL ", sqlL)}
|
||||
)
|
||||
UPDATE t0e SET t0e.FQTY = t0e.FQTY + (t1.QTY / t2.FDENOMINATOR * t2.FNUMERATOR)
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN #基础数据 t1 on t1.FBILLNO = t0.FBILLNO
|
||||
INNER JOIN T_ENG_BOMCHILD t2 on t2.FID = t0.FBOMID AND t2.FMATERIALID = t0e.FMATERIALID
|
||||
WHERE 1 = 1
|
||||
AND t0.FDOCUMENTSTATUS = 'C'
|
||||
";
|
||||
var res = DBUtils.Execute(this.Context, updSqlL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -127,13 +245,28 @@ UPDATE t0 SET t0.FQTY = t0.FQTY - t1.QTY
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
INNER JOIN #基础数据 t1 on t1.FBILLNO = t0.FBILLNO
|
||||
WHERE 1 = 1
|
||||
AND t0.FDOCUMENTSTATUS = 'C'
|
||||
AND (t0.FQTY - t1.QTY) >= 0
|
||||
|
||||
AND t0.FDOCUMENTSTATUS = 'C' AND (t0.FQTY - t1.QTY) >= 0
|
||||
";
|
||||
|
||||
//更新组装单信
|
||||
var resData = DBUtils.Execute(this.Context, updSqlL);
|
||||
if (resData > 0)
|
||||
{
|
||||
updSqlL = $@"/*dialect*/
|
||||
WITH #基础数据 AS (
|
||||
{string.Join(" UNION ALL ", sqlL)}
|
||||
)
|
||||
UPDATE t0e SET t0e.FQTY = t0e.FQTY - (t1.QTY / t2.FDENOMINATOR * t2.FNUMERATOR)
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN #基础数据 t1 on t1.FBILLNO = t0.FBILLNO
|
||||
INNER JOIN T_ENG_BOMCHILD t2 on t2.FID = t0.FBOMID
|
||||
AND t2.FMATERIALID = t0e.FMATERIALID
|
||||
WHERE 1 = 1 AND t0.FDOCUMENTSTATUS = 'C'
|
||||
|
||||
";
|
||||
var res = DBUtils.Execute(this.Context, updSqlL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
96
14.宝锐/GZ.LJY000.Biori/SAL_OUTSTOCK/OperationEventPlugInEx.py
Normal file
96
14.宝锐/GZ.LJY000.Biori/SAL_OUTSTOCK/OperationEventPlugInEx.py
Normal file
@@ -0,0 +1,96 @@
|
||||
#引入clr运行库
|
||||
import clr
|
||||
#添加对cloud插件开发的常用组件引用
|
||||
clr.AddReference('System')
|
||||
clr.AddReference('System.Data')
|
||||
clr.AddReference('Kingdee.BOS')
|
||||
clr.AddReference('Kingdee.BOS.Core')
|
||||
clr.AddReference('Kingdee.BOS.App')
|
||||
clr.AddReference('Kingdee.BOS.App.Core')
|
||||
clr.AddReference('Kingdee.BOS.Contracts')
|
||||
clr.AddReference('Kingdee.BOS.DataEntity')
|
||||
clr.AddReference('Kingdee.BOS.ServiceHelper')
|
||||
#dairycloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
|
||||
from Kingdee.BOS.Core import *
|
||||
from Kingdee.BOS.Util import *
|
||||
from Kingdee.BOS.Core.Bill import *
|
||||
from Kingdee.BOS.Core.List import *
|
||||
from Kingdee.BOS.Core.Bill.PlugIn import *
|
||||
from Kingdee.BOS.Orm.DataEntity import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
|
||||
from Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs import *
|
||||
from System import *
|
||||
from System.Data import *
|
||||
from Kingdee.BOS.App.Data import *
|
||||
from Kingdee.BOS.App import *
|
||||
from Kingdee.BOS.Orm import *
|
||||
from Kingdee.BOS.Contracts import *
|
||||
from System.Collections.Generic import List
|
||||
from Kingdee.BOS.ServiceHelper import *
|
||||
from Kingdee.BOS.App.Core import *
|
||||
|
||||
def OnPreparePropertys(e):
|
||||
e.FieldKeys.Add("FRowType");
|
||||
e.FieldKeys.Add("FPackBillNo");
|
||||
# e.FieldKeys.Add("FPackBillSeq");
|
||||
# e.FieldKeys.Add("FPackBillEntryId");
|
||||
e.FieldKeys.Add("FRealQty");
|
||||
e.FieldKeys.Add("FPackBarCode");
|
||||
|
||||
def BeforeDoSaveExecute(e):
|
||||
# if this.FormOperation.OperationId == 8:
|
||||
for entity in e.DataEntities:
|
||||
entries = entity["SAL_OUTSTOCKENTRY"]
|
||||
sqlL = List[str]();
|
||||
for idx,entry in enumerate(entries):
|
||||
rowType = 1 if entry["RowType"] == "Parent" else 2;
|
||||
if rowType == 2 or rowType == 1:
|
||||
packBarCode = "" if entry["FPackBarCode"] == None else entry["FPackBarCode"].strip()
|
||||
packBillNo = "" if entry["FPackBillNo"] == None else entry["FPackBillNo"].strip()
|
||||
|
||||
if (rowType == 1 and packBillNo == "") or (rowType == 2 and packBarCode != "" and packBillNo == ""):
|
||||
materialId = entry["MaterialID_Id"]
|
||||
entryId = entry["Id"]
|
||||
rowId = entry["RowId"]
|
||||
pRowId = entry["ParentRowId"]
|
||||
sqlL.Add("SELECT {0} 'MaterialId',{1} 'EntryId',{2} 'EntrySeq','{3}' AS 'PackBarCode',{4} AS 'FRowType','{5}' AS 'rowId','{6}' AS 'pRwoId'".format(materialId,entryId,idx,packBarCode,rowType,rowId,pRowId));
|
||||
|
||||
if sqlL.Count > 0:
|
||||
sqlUnion = " UNION ALL ".join(sqlL);
|
||||
sql = """/*dialect*/
|
||||
|
||||
WITH #基础数据 AS (
|
||||
{0}
|
||||
)
|
||||
, #初步处理 AS (
|
||||
SELECT t0.MaterialId,t0.EntryId,t0.EntrySeq
|
||||
,CASE WHEN t0.FRowType = 1 THEN (
|
||||
SELECT TOP 1 t1.PackBarCode FROM #基础数据 t1 WHERE t1.pRwoId = t0.rowId
|
||||
) ELSE t0.PackBarCode END 'PackBarCode'
|
||||
,t0.FRowType,t0.rowId,t0.pRwoId
|
||||
FROM #基础数据 t0
|
||||
)
|
||||
SELECT tt.*
|
||||
,t0.FBARCODE,t1.FBILLNO,t0.FBILLID,t0.FBILLENTRYID,t0.FBILLSEQ,t0.FBILLFORMID
|
||||
FROM #初步处理 tt
|
||||
INNER JOIN T_UNW_WMS_BARCODE t0 on t0.FBARCODE = tt.PackBarCode
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCK t1 on t1.FSRCBILLENTRYID = t0.FBILLENTRYID
|
||||
WHERE t0.FBILLFORMID = 'PLN_FORECAST'
|
||||
ORDER BY tt.EntrySeq
|
||||
|
||||
""".format(sqlUnion);
|
||||
# raise Exception(sql);
|
||||
|
||||
res = DBServiceHelper.ExecuteDynamicObject(this.Context, sql)
|
||||
|
||||
if res != None and res.Count > 0:
|
||||
for item in res:
|
||||
seq = item["EntrySeq"];
|
||||
entries[seq]["FPackBarCode"] = item["PackBarCode"];
|
||||
entries[seq]["FPackBillNo"] = item["FBILLNO"];
|
||||
# entries[seq]["FPackBillSeq"] = item["FSeq"];
|
||||
# entries[seq]["FPackBillEntryId"] = item["FEntryID"];
|
||||
|
||||
return;
|
||||
Reference in New Issue
Block a user