a
This commit is contained in:
@@ -18,8 +18,6 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
[Description("预测单下推组装入库单#"), HotUpdate]
|
||||
public class BillConvertEventPlugInEx : AbstractConvertPlugIn
|
||||
{
|
||||
|
||||
|
||||
public override void AfterConvert(AfterConvertEventArgs e)
|
||||
{
|
||||
base.AfterConvert(e);
|
||||
@@ -68,6 +66,7 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
,ISNULL(t2.生产日期,'') '生产日期'
|
||||
,ISNULL(t2.有效期至,'') '有效期至'
|
||||
,ROW_NUMBER() OVER(ORDER BY t0.FSEQ) RN
|
||||
,ISNULL(t3.RptQty,0) 'RptQty'
|
||||
FROM #预测单数据 t0
|
||||
INNER JOIN T_BD_MATERIAL t1 on t1.FMATERIALID = t0.FMATERIALID
|
||||
INNER JOIN T_BD_MATERIAL_L t1_l on t1_l.FMATERIALID = t0.FMATERIALID AND t1_l.FLOCALEID = 2052
|
||||
@@ -88,12 +87,22 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
,ISNULL(CONVERT(varchar(100),t2e.F_UHIK_DATE,20),'') '生产日期',ISNULL(CONVERT(varchar(100),t2e.F_UHIK_DATE1,20),'') '有效期至'
|
||||
FROM T_PRD_MO t2
|
||||
INNER JOIN T_PRD_MOENTRY t2e on t2.FID = t2e.FID
|
||||
INNER JOIN T_PRD_MOENTRY_A t2e_a on t2e.FENTRYID = t2e_a.FENTRYID AND t2e_a.FREQSRC = 2
|
||||
INNER JOIN T_PRD_MOENTRY_A t2e_a on t2e.FENTRYID = t2e_a.FENTRYID
|
||||
WHERE 1 = 1 AND t2e.FPackSrcBillNo = t0.FBILLNO AND t2e.FFPackSrcSeq = t0.FSEQ AND t2e.FPackSrcType = 1
|
||||
AND t2e.FMATERIALID = t0.FMATERIALID
|
||||
) t2
|
||||
OUTER APPLY (
|
||||
SELECT t3e_lk.FSID,SUM(t3e_a.FBASESTOCKINQUASELQTY) RptQty
|
||||
FROM T_PRD_MORPT t3
|
||||
INNER JOIN T_PRD_MORPTENTRY t3e on t3.FID = t3e.FID
|
||||
INNER JOIN T_PRD_MORPTENTRY_A t3e_a on t3e_a.FENTRYID = t3e.FENTRYID
|
||||
INNER JOIN T_PRD_MORPTENTRY_LK t3e_lk on t3e_lk.FENTRYID = t3e.FENTRYID AND t3e_lk.FSTABLENAME = 'T_PRD_MOENTRY'
|
||||
WHERE t3e_lk.FSID = t2.MoEntryId
|
||||
GROUP BY t3e_lk.FSID
|
||||
) t3
|
||||
|
||||
";
|
||||
|
||||
var dataList = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
if (dataList != null && dataList.Any())
|
||||
{
|
||||
@@ -210,7 +219,8 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
entry["FFYLQty"] = item["F_FYL_QTY"];
|
||||
|
||||
entry["FQty"] = item["FQTY"];
|
||||
entry["FRptQty"] = item["FQTY"];
|
||||
//entry["FRptQty"] = item["FQTY"];
|
||||
entry["FRptQty"] = item["RptQty"];
|
||||
entry["FNoInStockQty"] = item["FQTY"];
|
||||
|
||||
entrys.Add(entry);
|
||||
@@ -226,11 +236,6 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
base.OnParseFilterOptions(e);
|
||||
}
|
||||
|
||||
public override void OnParseFilter(ParseFilterEventArgs e)
|
||||
{
|
||||
base.OnParseFilter(e);
|
||||
}
|
||||
|
||||
public override void OnInitVariable(InitVariableEventArgs e)
|
||||
{
|
||||
base.OnInitVariable(e);
|
||||
|
||||
@@ -17,8 +17,19 @@ from System.Data import *
|
||||
from System.Collections.Generic import *
|
||||
from Kingdee.BOS.ServiceHelper import *
|
||||
|
||||
def OnParseFilterOptions(e):
|
||||
raise Exception(e.FilterOptionsSQL)
|
||||
# python:已生成条码的数据不能重复生成!
|
||||
def OnParseFilter(e):
|
||||
# raise Exception(e.FilterPolicySQL)
|
||||
fromId = e.SourceBusinessInfo.GetForm().Id;
|
||||
e.FilterPolicySQL = e.FilterPolicySQL + """
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM T_PRD_MOASSEMBLE_LK uwbc
|
||||
WHERE uwbc.FSID = t0.FID
|
||||
AND uwbc.FSTableName = 'T_PLN_FORECAST1'
|
||||
)
|
||||
"""
|
||||
e.PlugFilterDesc = "已生成组装单的数据不能重复生成!";
|
||||
return;
|
||||
|
||||
# def OnParseFilter(e):
|
||||
# raise Exception(e.FilterPolicySQL)
|
||||
|
||||
@@ -17,7 +17,6 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK.GET_PACKGE_INFO
|
||||
{
|
||||
@@ -34,34 +33,30 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK.GET_PACKGE_INFO
|
||||
}
|
||||
|
||||
string scanCode = e.Value.ToString();
|
||||
scanCode = scanCode.Long2Int() == 0 ? scanCode : GetBarCode(scanCode);
|
||||
//scanCode = scanCode.Long2Int() == 0 ? scanCode : GetBarCode(scanCode);
|
||||
if (scanCode.IsNullOrEmptyOrWhiteSpace())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var scanCodeInfos = scanCode.Split('_');
|
||||
if (scanCodeInfos.Length < 4)
|
||||
{
|
||||
this.View.Model.SetValue("FMsg", "无效的二维码!");
|
||||
this.View.GetControl("FMsg").SetCustomPropertyValue("ForeColor", "#FF3300");
|
||||
return;
|
||||
}
|
||||
|
||||
var billNo = scanCodeInfos[0];
|
||||
|
||||
var sqlL = $@"/*dialect*/
|
||||
WITH #基础数据 AS (
|
||||
SELECT t0.FBILLNO,t0e.FENTRYID,t0e.FSeq,t0e.FMATERIALID,t0e.FLOT,t0e.FLOT_Text,t0e.FPRINTMODEL
|
||||
WITH #条码信息 AS (
|
||||
SELECT t0.FBARCODE,t0.FBillNo,t0.FBILLSEQ,t0.FBILLFORMID
|
||||
FROM T_UNW_WMS_BARCODE t0
|
||||
WHERE t0.FBARCODE = '{scanCode}'
|
||||
AND t0.FBILLFORMID = 'PLN_FORECAST'
|
||||
AND t0.FBILLSEQ = 1
|
||||
)
|
||||
, #基础数据 AS (
|
||||
SELECT t0.FBILLNO,t0.FSRCBILLNO,t0e.FENTRYID,t0e.FSeq,t0e.FMATERIALID,t0e.FLOT,t0e.FLOT_Text,t0e.FPRINTMODEL
|
||||
,t0e.FGZLQTY,t0e.FZGSQTY,t0e.FQTY,t0e.FPRODUCEDDATE,t0e.FEXPIRYDATE
|
||||
,t0e.FFYLQTY,t0e.FUNITID
|
||||
,t0.FSRCBILLTYPE,t0e.FSRCBILLENTRYID
|
||||
,t0e.FFYLQTY,t0e.FUNITID,t0.FSRCBILLTYPE,t0e.FSRCBILLENTRYID
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
WHERE 1=1 AND t0.FDOCUMENTSTATUS = 'C'
|
||||
AND t0.FQTY > 0
|
||||
UNION ALL
|
||||
SELECT t0.FBILLNO,0,0 FSEQ,t0.FMATERIALID,t0.FLOT,t0.FLOT_Text,t0.FPRINTMODEL
|
||||
SELECT t0.FBILLNO,t0.FSRCBILLNO,0,0 FSEQ,t0.FMATERIALID,t0.FLOT,t0.FLOT_Text,t0.FPRINTMODEL
|
||||
,0,0,t0.FQTY,t0.FPRODUCTDATE,t0.FEXPIRYDATE,t0.FFYLQTY,t0.FUNITID
|
||||
,t0.FSRCBILLTYPE,t0.FSRCBILLENTRYID
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
@@ -69,7 +64,8 @@ WITH #基础数据 AS (
|
||||
AND t0.FQTY > 0
|
||||
)
|
||||
SELECT t0.*,t1.*
|
||||
FROM #基础数据 t0
|
||||
FROM #条码信息 tt
|
||||
INNER JOIN #基础数据 t0 on tt.FBillNo = t0.FSRCBILLNO
|
||||
CROSS APPLY (
|
||||
SELECT t1e.FROWID,t1e.FPARENTROWID,t1.FBILLNO
|
||||
FROM T_PLN_FORECAST t1
|
||||
@@ -83,7 +79,7 @@ FROM #基础数据 t0
|
||||
WHERE t0.FSRCBILLTYPE = 'SAL_ORDER' AND t1e.FENTRYID = t0.FSRCBILLENTRYID
|
||||
) t1
|
||||
WHERE 1 = 1
|
||||
AND t0.FBILLNO = '{billNo}'
|
||||
--AND t0.FSRCBILLNO = 'FO00001306'
|
||||
ORDER BY FSeq
|
||||
";
|
||||
|
||||
@@ -147,14 +143,15 @@ ORDER BY FSeq
|
||||
|
||||
this.View.Model.SetValue("FMsg", "取值成功!");
|
||||
this.View.GetControl("FMsg").SetCustomPropertyValue("ForeColor", "#00994C");
|
||||
this.View.UpdateView("FEntity");
|
||||
//this.View.UpdateView("FEntity");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.View.Model.SetValue("FMsg", "无效条码!");
|
||||
this.View.Model.SetValue("FMsg", "条码信息不存在或组转单信息不存在!");
|
||||
this.View.GetControl("FMsg").SetCustomPropertyValue("ForeColor", "#FF3300");
|
||||
return;
|
||||
//return;
|
||||
}
|
||||
|
||||
e.Value = "";
|
||||
var control = this.View.GetControl("FScanBarCode");
|
||||
control.SetFocus();
|
||||
|
||||
@@ -19,10 +19,12 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.K3.BD.BarCode.Core.DataModel.WebApi;
|
||||
|
||||
namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
{
|
||||
[HotUpdate, Description("组装单生成汇报单")]
|
||||
[HotUpdate, Description("组装单服务插件#")]
|
||||
public class OperationEventPlugInEx : AbstractOperationServicePlugIn
|
||||
{
|
||||
public override void OnPreparePropertys(PreparePropertysEventArgs e)
|
||||
@@ -30,34 +32,59 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
base.OnPreparePropertys(e);
|
||||
|
||||
e.FieldKeys.Add("FPMoBillTypeId");
|
||||
e.FieldKeys.Add("FMoillTypeId_Id");
|
||||
e.FieldKeys.Add("FPSrcBillEntryId");
|
||||
e.FieldKeys.Add("FMoBillTypeId_Id");
|
||||
e.FieldKeys.Add("FMoId");
|
||||
e.FieldKeys.Add("FMoEntryId");
|
||||
e.FieldKeys.Add("FMoBillTypeId");
|
||||
e.FieldKeys.Add("FMOBillNo");
|
||||
e.FieldKeys.Add("FCreateMORpt");
|
||||
e.FieldKeys.Add("FQty");
|
||||
e.FieldKeys.Add("FRptQty");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public override void EndOperationTransaction(EndOperationTransactionArgs e)
|
||||
{
|
||||
base.EndOperationTransaction(e);
|
||||
|
||||
// 保存8提交9审核1反审核26
|
||||
if (this.FormOperation.OperationId == 1)
|
||||
{
|
||||
var dataEntityList = new List<DynamicObject>();
|
||||
|
||||
var billNos = new List<string>();
|
||||
//this.Context.UserId
|
||||
//this.Context.CurrentOrganizationInfo.ID
|
||||
#region 生成汇报单
|
||||
var dataEntityList = new List<DynamicObject>();
|
||||
foreach (var data in e.DataEntitys)
|
||||
{
|
||||
var srcBillEntryId = data["FPSrcBillEntryId"];
|
||||
if (srcBillEntryId != null && srcBillEntryId.Long2Int() > 0)
|
||||
dataEntityList.Add(data);
|
||||
|
||||
if (dataEntityList.Any())
|
||||
DoCreateMoRpt(dataEntityList);
|
||||
if (!Convert.ToBoolean(data["FCreateMORpt"]))
|
||||
continue;
|
||||
|
||||
var srcBillEntryId = data["FPSrcBillEntryId"];
|
||||
|
||||
if (srcBillEntryId != null && srcBillEntryId.Long2Int() > 0)
|
||||
{
|
||||
dataEntityList.Add(data);
|
||||
}
|
||||
}
|
||||
|
||||
if (dataEntityList.Any())
|
||||
DoCreateMoRpt(dataEntityList);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 生成条码装箱单
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
private void DoCreateMoRpt(List<DynamicObject> dataEntitys)
|
||||
private void DoCreateMoRpt2(List<DynamicObject> dataEntitys)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -89,10 +116,21 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
if (policie7009 == null)
|
||||
throw new Exception("转换单据中,单据类型属性类型值:7009不存在。");
|
||||
|
||||
if (policie7002 == null)
|
||||
throw new Exception("转换单据中,单据类型属性类型值:7002不存在。");
|
||||
|
||||
var ids = new List<int>();
|
||||
|
||||
foreach (var item in dataEntitys)
|
||||
{
|
||||
foreach (var entity in item["FEntity"] as DynamicObjectCollection)
|
||||
{
|
||||
var rptQty = Convert.ToDecimal(entity["FRptQty"]);
|
||||
var qty = Convert.ToDecimal(entity["FQty"]);
|
||||
|
||||
if (qty <= rptQty)
|
||||
continue;
|
||||
|
||||
var sourceBillTypeId = entity["FMoBillTypeId_Id"].ToString();
|
||||
var billTypeMap = policie7009.BillTypeMaps.FirstOrDefault(x => x.SourceBillTypeId == sourceBillTypeId);
|
||||
|
||||
@@ -131,9 +169,186 @@ namespace GZ.LJY000.Biori.UHIK_PRD_PACKAGE_INSTOCK
|
||||
|
||||
throw new KDBusinessException("", "未知原因导致自动保存失败原因:" + JsonUtil.SerializeWithOutNull(saveResult));
|
||||
}
|
||||
ids.Add(entity["Id"].Long2Int());
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.Any())
|
||||
{
|
||||
|
||||
var updSql = $@"/*dialect*/
|
||||
UPDATE t3e SET t3e.FRPTQTY = ISNULL(t1.选单入库合格数量,0)
|
||||
FROM T_PRD_MO t0
|
||||
INNER JOIN T_PRD_MOENTRY t0e on t0.FID = t0e.FID
|
||||
OUTER APPLY (
|
||||
SELECT t1e.FMOENTRYID,t1e.FMOBILLNO,SUM(t1e.FFINISHQTY) '选单入库合格数量'
|
||||
FROM T_PRD_MORPT t1
|
||||
INNER JOIN T_PRD_MORPTENTRY t1e on t1.FID = t1e.FID
|
||||
INNER JOIN T_PRD_MORPTENTRY_A t1e_a on t1e_a.FENTRYID = t1e.FENTRYID
|
||||
WHERE t1e.FMOENTRYID = t0e.FENTRYID
|
||||
AND t1.FDOCUMENTSTATUS = 'C'
|
||||
GROUP BY t1e.FMOENTRYID,t1e.FMOBILLNO
|
||||
) t1
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t3e on t3e.FMOENTRYID = t0e.FENTRYID
|
||||
WHERE 1 = 1
|
||||
AND t0.FDOCUMENTSTATUS = 'C'
|
||||
AND t3e.FEntryID IN ({string.Join(",", ids)})
|
||||
|
||||
";
|
||||
|
||||
var isOk = DBServiceHelper.Execute(this.Context, updSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void DoCreateMoRpt(List<DynamicObject> dataEntitys)
|
||||
{
|
||||
try
|
||||
{
|
||||
IConvertService service = ServiceHelper.GetService<IConvertService>();
|
||||
|
||||
//获取元数据服务
|
||||
IMetaDataService metadataService = ServiceHelper.GetService<IMetaDataService>();
|
||||
|
||||
//获取ViewService
|
||||
IViewService viewService = ServiceHelper.GetService<IViewService>();
|
||||
//获取源单元数据
|
||||
|
||||
//# *源单据标识
|
||||
var sourceFormId = "PRD_MO";
|
||||
//# *目标单据标识
|
||||
var targetFormId = "PRD_MORPT";
|
||||
|
||||
var convertRuleId = "PRD_MO2MORPT";
|
||||
|
||||
var ruleMeta = service.GetConvertRule(this.Context, convertRuleId);
|
||||
|
||||
if (ruleMeta != null)
|
||||
{
|
||||
FormMetadata sourceMetada = metadataService.Load(this.Context, sourceFormId) as FormMetadata;
|
||||
|
||||
var policies = ruleMeta.Rule.Policies;
|
||||
var policie7002 = policies.FirstOrDefault(x => x.ElementType == 7002) as DefaultConvertPolicyElement;
|
||||
var policie7009 = policies.FirstOrDefault(x => x.ElementType == 7009) as BillTypeMapPolicyElement;
|
||||
if (policie7009 == null)
|
||||
throw new Exception("转换单据中,单据类型属性类型值:7009不存在。");
|
||||
|
||||
if (policie7002 == null)
|
||||
throw new Exception("转换单据中,单据类型属性类型值:7002不存在。");
|
||||
|
||||
var ids = new List<int>();
|
||||
|
||||
foreach (var item in dataEntitys)
|
||||
{
|
||||
|
||||
var sourceBillDict = new Dictionary<string, List<ListSelectedRow>>();
|
||||
var sourceBillTypeDict = new Dictionary<string, string>();
|
||||
var packEntryIds = new Dictionary<string, List<int>>();
|
||||
|
||||
foreach (var entity in item["FEntity"] as DynamicObjectCollection)
|
||||
{
|
||||
var rptQty = Convert.ToDecimal(entity["FRptQty"]);
|
||||
var qty = Convert.ToDecimal(entity["FQty"]);
|
||||
|
||||
if (qty <= rptQty)
|
||||
continue;
|
||||
|
||||
var sourceBillTypeId = entity["FMoBillTypeId_Id"].ToString();
|
||||
var billTypeMap = policie7009.BillTypeMaps.FirstOrDefault(x => x.SourceBillTypeId == sourceBillTypeId);
|
||||
|
||||
if (billTypeMap == null)
|
||||
throw new Exception($"转换规则中,{sourceBillTypeId}源单单据类型不存在!");
|
||||
|
||||
if (!sourceBillDict.ContainsKey(sourceBillTypeId))
|
||||
sourceBillDict.Add(sourceBillTypeId, new List<ListSelectedRow>());
|
||||
|
||||
sourceBillDict[sourceBillTypeId].Add(new ListSelectedRow("0", entity["FMoEntryId"].ToString(), 0, sourceFormId) { EntryEntityKey = policie7002.SourceEntryKey });
|
||||
|
||||
if (!sourceBillTypeDict.ContainsKey(sourceBillTypeId))
|
||||
sourceBillTypeDict.Add(sourceBillTypeId, billTypeMap.TargetBillTypeId);
|
||||
|
||||
if (!packEntryIds.ContainsKey(sourceBillTypeId))
|
||||
packEntryIds.Add(sourceBillTypeId, new List<int>());
|
||||
|
||||
packEntryIds[sourceBillTypeId].Add(entity["Id"].Long2Int());
|
||||
}
|
||||
|
||||
foreach (var dict in sourceBillDict)
|
||||
{
|
||||
var selectedRows = dict.Value;
|
||||
//selectedRows.Add(new ListSelectedRow("0", entity["FMoEntryId"].ToString(), 0, sourceFormId) { EntryEntityKey = policie7002.SourceEntryKey });
|
||||
var pushArgs = new PushArgs(ruleMeta.Rule, selectedRows.ToArray());
|
||||
//pushArgs.TargetBillTypeId = billTypeMap.TargetBillTypeId;
|
||||
pushArgs.TargetBillTypeId = sourceBillTypeDict[dict.Key];
|
||||
OperateOption option = OperateOption.Create();//选项参数
|
||||
//不按照整单下推
|
||||
option.SetVariableValue(ConvertConst.SelectByBillId, false);
|
||||
|
||||
//源单数据转换目标数据
|
||||
ConvertOperationResult convertResult = service.Push(this.Context, pushArgs, option);
|
||||
|
||||
DynamicObject[] destObjs = convertResult.TargetDataEntities.Select(r => r.DataEntity).ToArray();
|
||||
|
||||
FormMetadata destFormMetadata = metadataService.Load(this.Context, targetFormId) as FormMetadata;
|
||||
|
||||
string msg = string.Empty;
|
||||
|
||||
#region 自动保存
|
||||
IOperationResult saveResult = ServiceHelper.GetService<ISaveService>().SaveAndAudit(this.Context, destFormMetadata.BusinessInfo, destObjs, OperateOption.Create());
|
||||
|
||||
if (!saveResult.IsSuccess)
|
||||
{
|
||||
if (saveResult.ValidationErrors != null && saveResult.ValidationErrors.Count > 0)
|
||||
{
|
||||
var errorInfo = string.Join(";", saveResult.ValidationErrors.Select(x => x.Message));
|
||||
|
||||
throw new KDBusinessException("", "未知原因导致自动保存失败原因:" + errorInfo);
|
||||
}
|
||||
|
||||
throw new KDBusinessException("", "未知原因导致自动保存失败原因:" + JsonUtil.SerializeWithOutNull(saveResult));
|
||||
}
|
||||
|
||||
ids.AddRange(packEntryIds[dict.Key]);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.Any())
|
||||
{
|
||||
|
||||
var updSql = $@"/*dialect*/
|
||||
UPDATE t3e SET t3e.FRPTQTY = ISNULL(t1.选单入库合格数量,0)
|
||||
FROM T_PRD_MO t0
|
||||
INNER JOIN T_PRD_MOENTRY t0e on t0.FID = t0e.FID
|
||||
OUTER APPLY (
|
||||
SELECT t1e.FMOENTRYID,t1e.FMOBILLNO,SUM(t1e.FFINISHQTY) '选单入库合格数量'
|
||||
FROM T_PRD_MORPT t1
|
||||
INNER JOIN T_PRD_MORPTENTRY t1e on t1.FID = t1e.FID
|
||||
INNER JOIN T_PRD_MORPTENTRY_A t1e_a on t1e_a.FENTRYID = t1e.FENTRYID
|
||||
WHERE t1e.FMOENTRYID = t0e.FENTRYID
|
||||
AND t1.FDOCUMENTSTATUS = 'C'
|
||||
GROUP BY t1e.FMOENTRYID,t1e.FMOBILLNO
|
||||
) t1
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t3e on t3e.FMOENTRYID = t0e.FENTRYID
|
||||
WHERE 1 = 1
|
||||
AND t0.FDOCUMENTSTATUS = 'C'
|
||||
AND t3e.FEntryID IN ({string.Join(",", ids)})
|
||||
|
||||
";
|
||||
|
||||
var isOk = DBServiceHelper.Execute(this.Context, updSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -42,100 +42,76 @@ def OnPreparePropertys(e):
|
||||
def EndOperationTransaction(e):
|
||||
# * 保存8提交9审核1反审核26删除3
|
||||
if this.FormOperation.OperationId == 1:
|
||||
# raise Exception(JsonUtil.Serialize(e.DataEntitys))
|
||||
billNos = List[str]();
|
||||
for item in e.DataEntitys:
|
||||
DoCreatePackCode(item["BillNo"])
|
||||
|
||||
# 建立条码组装单
|
||||
def DoCreatePackCode(billNo):
|
||||
if billNo != "":
|
||||
sqlL = """/*dialect*/
|
||||
WITH #基础数据 AS (
|
||||
SELECT t0.FBILLNO AS 'packBillNo',t0.FMATERIALID,0 packEntryId,0 packSeq
|
||||
,ISNULL(t2.FID,0) 'barCodeId'
|
||||
,t2.FBARCODE
|
||||
,ISNULL(t2.FQTY,0) FQTY,ISNULL(t3.FID,0) packId
|
||||
,t0.FBILLNO,1 IS_Main,1 FYLRate
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
LEFT JOIN T_UNW_WMS_BARCODE t2 on t2.FBILLENTRYID = t0.FSRCBILLENTRYID AND t2.FBILLFORMID = 'PLN_FORECAST'
|
||||
LEFT JOIN T_UNW_WMS_PACKING t3 on t3.FBOXCODEID = t2.FID
|
||||
UNION ALL
|
||||
SELECT t0.FBILLNO AS 'packBillNo',t0e.FMATERIALID
|
||||
,t0e.FEntryID
|
||||
,t0e.FSeq
|
||||
,ISNULL(t2.FID,0) 'barCodeId'
|
||||
,t2.FBARCODE
|
||||
,ISNULL(t2.FQTY,0) FQTY,ISNULL(t3e.FID,0) packId
|
||||
,t0.FBILLNO,0,1.05
|
||||
FROM T_PRD_PACKAGEINSTOCK t0
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
LEFT JOIN T_UNW_WMS_BARCODE t2 on t2.FBILLENTRYID = t0e.FMOENTRYID AND t2.FBILLFORMID = 'PRD_MO'
|
||||
LEFT JOIN T_UNW_WMS_PACKINGENTRY t3e on t3e.FBARCODEID = t2.FID
|
||||
)
|
||||
SELECT t0.packBillNo,t0.IS_Main,t0.FMATERIALID,SUM(t0.FQTY) / t0.FYLRate FQTY,MAX(t0.barCodeId) barCodeId
|
||||
FROM #基础数据 t0
|
||||
WHERE t0.FBILLNO = '{0}'
|
||||
GROUP BY t0.packBillNo,t0.IS_Main,t0.FMATERIALID,t0.FYLRate
|
||||
ORDER BY t0.IS_Main DESC
|
||||
|
||||
""".format(billNo)
|
||||
dataList = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
if dataList != None and dataList.Count > 0:
|
||||
|
||||
formID = "UNW_WMS_PACKING";
|
||||
|
||||
meta = MetaDataServiceHelper.Load(this.Context, formID)
|
||||
objType = meta.BusinessInfo.GetDynamicObjectType();
|
||||
newObj = DynamicObject(objType)
|
||||
|
||||
main = dataList[0];
|
||||
if main["IS_Main"] == 1:
|
||||
if main["barCodeId"] == 0:
|
||||
raise Exception("条码装箱单套件码未生成!")
|
||||
|
||||
newObj["BoxCodeId_Id"] = main["barCodeId"]
|
||||
newObj["Capacity"] = main["FQTY"]
|
||||
newObj["CreateOrgId_Id"] = this.Context.CurrentOrganizationInfo.ID
|
||||
newObj["CreatorId_Id"] = this.Context.UserId
|
||||
newObj["ModifierId_Id"] = this.Context.UserId
|
||||
entry = newObj["List"]
|
||||
for item in dataList:
|
||||
if item["IS_Main"] == 0:
|
||||
if item["barCodeId"] == 0:
|
||||
raise Exception("分录【{0}】条码未生成!".format(item["packSeq"]))
|
||||
|
||||
entity = entry.DynamicCollectionItemPropertyType.CreateInstance()
|
||||
entity["BarCodeId_Id"] = item["barCodeId"]
|
||||
entity["Qty"] = item["FQTY"]
|
||||
entry.Add(entity)
|
||||
|
||||
ObjList = List[DynamicObject]();#单据的数据包集合
|
||||
if entry.Count > 0:
|
||||
ObjList.Add(newObj);
|
||||
saveRslt = BusinessDataServiceHelper.Save(this.Context, meta.BusinessInfo ,ObjList.ToArray(), None, "Save");
|
||||
# raise Exception(JsonUtil.Serialize(newObj))
|
||||
|
||||
dataEntityList = List[DynamicObject]()
|
||||
|
||||
for data in e.DataEntitys:
|
||||
srcBillEntryId = data["FPSrcBillEntryId"]
|
||||
if srcBillEntryId != None and srcBillEntryId > 0:
|
||||
dataEntityList.Add(data)
|
||||
|
||||
if dataEntityList.Count > 0:
|
||||
DoCreateMoRpt(dataEntityList)
|
||||
|
||||
def DoCreateMoRpt(dataEntitys):
|
||||
"""组装入库单审核后生成汇报单
|
||||
|
||||
Args:
|
||||
dataEntitys (_type_): 数据集
|
||||
|
||||
Raises:
|
||||
Exception: _description_
|
||||
Exception: _description_
|
||||
Exception: _description_
|
||||
"""
|
||||
# raise Exception(JsonUtil.Serialize(dataEntitys))
|
||||
# service = ServiceHelper.GetService[IConvertService]();
|
||||
|
||||
ctx = this.Context;
|
||||
service = ConvertService();
|
||||
# *源单据标识
|
||||
sourceFormId = "PRD_MO";
|
||||
|
||||
# *目标单据标识
|
||||
targetFormId = "PRD_MORPT";
|
||||
|
||||
# ruleMetaList = service.GetRulesByFormId(this.Context,sourceFormId,targetFormId)
|
||||
|
||||
# raise Exception(JsonUtil.Serialize(ruleMetaList))
|
||||
convertRuleId = "PRD_MO2MORPT"
|
||||
ruleMeta = service.GetConvertRule(this.Context,convertRuleId)
|
||||
|
||||
# ! 装管公式(毫升):管数 = 数量 / 装管量(ml) / 1.05
|
||||
# ! 装管公式(微升):管数 = 数量 / 装管量(ml) / 1000 / 1.05
|
||||
if ruleMeta != None:
|
||||
policies = ruleMeta.Rule.Policies
|
||||
billTypeElement = FirstOrDefault(policies,lambda x: x.ElementType == 7009)
|
||||
if billTypeElement == None:
|
||||
raise Exception("转换单据中,单据类型属性类型值:7009不存在。")
|
||||
|
||||
for item in dataEntitys:
|
||||
for entity in item.FEntity:
|
||||
raise Exception(JsonUtil.Serialize(entity))
|
||||
# 来源单据工单类型
|
||||
sourceBillTypeId = item["FPMoBillTypeId_Id"]
|
||||
|
||||
# 单据转换匹配类型
|
||||
billTypeMap = FirstOrDefault(billTypeElement.BillTypeMaps,lambda x: x.SourceBillTypeId == sourceBillTypeId);
|
||||
|
||||
if billTypeMap == None:
|
||||
raise Exception("转换规则中,工单单据类型不存在!")
|
||||
|
||||
# 单据下推设置
|
||||
selectedRows = List[ListSelectedRow]();
|
||||
selectedRows.AddRange(list(map(lambda x : ListSelectedRow(str(x.FMoId), str(x.FMoEntryId) ,0 ,sourceFormId),item.FEntity)))
|
||||
pushArgs = PushArgs(ruleMeta.Rule, selectedRows.ToArray())
|
||||
pushArgs.TargetBillTypeId = billTypeMap.TargetBillTypeId
|
||||
|
||||
# !转换服务
|
||||
convertResult = service.Push(this.Context , pushArgs, OperateOption.Create());
|
||||
destObjs = List[DynamicObject]()
|
||||
destObjs.AddRange(map(lambda x:x.DataEntity ,convertResult.TargetDataEntities))
|
||||
# raise Exception(JsonUtil.Serialize(destObjs))
|
||||
|
||||
# !单据加载服务
|
||||
metaDataService = MetaDataService()
|
||||
destFormMetadata = metaDataService.Load(ctx, targetFormId)
|
||||
|
||||
# !保存服务
|
||||
saveService = SaveService()
|
||||
saveResult = saveService.Save(ctx, destFormMetadata.BusinessInfo, destObjs.ToArray(), OperateOption.Create());
|
||||
|
||||
msg = "";
|
||||
|
||||
# 操作结果校验
|
||||
if saveResult.ValidationErrors != None and saveResult.ValidationErrors.Count > 0:
|
||||
errorInfoList = list(map(lambda x : x.Message,saveResult.ValidationErrors))
|
||||
errorInfo = ";".join(errorInfoList);
|
||||
|
||||
raise Exception("未知原因导致自动保存失败原因:"+ errorInfo)
|
||||
|
||||
# raise Exception(JsonUtil.Serialize(pushArgs))
|
||||
|
||||
def FirstOrDefault(collection, func):
|
||||
result = filter(func, collection)
|
||||
|
||||
if len(result) == 0: return None
|
||||
|
||||
return result[0]
|
||||
Reference in New Issue
Block a user