|
|
@@ -216,13 +216,24 @@ namespace JLHHJSvr.Helper
|
|
|
public List<u_softbed_mx> GetSoftBedMxBomList(List<u_configure_codemx> codeList)
|
|
|
{
|
|
|
var mxlist = new List<u_softbed_mx>();
|
|
|
- foreach(var code in codeList)
|
|
|
- {
|
|
|
- var resultList = new List<u_configure_codemxbom>();
|
|
|
- var outputFields = @"pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,cost,sonloss,sonloss_formula,
|
|
|
+
|
|
|
+ #region 临时表
|
|
|
+ var dt = new DataTable();
|
|
|
+ dt.Columns.Add("pzid", typeof(int));
|
|
|
+ dt.Columns.Add("printid", typeof(int));
|
|
|
+ dt.Columns.Add("has_type", typeof(byte));
|
|
|
+ foreach(var code in codeList)
|
|
|
+ {
|
|
|
+ dt.Rows.Add(code.pzid, code.printid,code.has_type);
|
|
|
+ }
|
|
|
+ TempTableHelper.CreateAndBulkInsert(cmd, "#CodeMxBom",dt);
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ var resultList = new List<u_configure_codemxbom>();
|
|
|
+ var outputFields = @"pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,cost,sonloss,sonloss_formula,
|
|
|
sondecloss,sondecloss_formula,default_length,default_width,default_qty,mtrlcode,mtrlname,mtrlmode,unit,
|
|
|
- mtrlsectype,zxmtrlmode,usermtrlmode,price,pzname";
|
|
|
- var selectStr = @"SELECT u_configure_codemxbom.pzid
|
|
|
+ mtrlsectype,zxmtrlmode,usermtrlmode,price,pzname,pznamemx,has_type";
|
|
|
+ var selectStr = @"SELECT u_configure_codemxbom.pzid
|
|
|
,u_configure_codemxbom.printid
|
|
|
,u_configure_codemxbom.pid
|
|
|
,u_configure_codemxbom.mtrlid
|
|
|
@@ -247,22 +258,22 @@ namespace JLHHJSvr.Helper
|
|
|
,u_mtrldef.zxmtrlmode
|
|
|
,u_mtrldef.usermtrlmode
|
|
|
,u_erpmtrl_price.price
|
|
|
- ,u_configure_codemx.namemx AS pzname
|
|
|
+ ,u_configure_codemx.namemx AS pznamemx
|
|
|
+ ,u_configure_code.name AS pzname
|
|
|
+ ,k.has_type
|
|
|
FROM u_configure_codemxbom
|
|
|
+ INNER JOIN #CodeMxBom k ON u_configure_codemxbom.pzid = k.pzid AND u_configure_codemxbom.printid = k.printid
|
|
|
INNER JOIN u_configure_codemx ON u_configure_codemxbom.pzid = u_configure_codemx.pzid
|
|
|
AND u_configure_codemxbom.printid = u_configure_codemx.printid
|
|
|
+ INNER JOIN u_configure_code ON u_configure_codemx.pzid = u_configure_code.pzid
|
|
|
INNER JOIN u_mtrldef ON u_configure_codemxbom.mtrlid = u_mtrldef.mtrlid
|
|
|
LEFT OUTER JOIN u_erpmtrl_price ON u_configure_codemxbom.mtrlid = u_erpmtrl_price.mtrlid";
|
|
|
- DbSqlHelper.SelectJoin(cmd,selectStr,
|
|
|
- "u_configure_codemxbom.pzid = @pzid AND u_configure_codemxbom.printid = @printid",
|
|
|
- new Dictionary<string, object>() { { "@pzid", code.pzid }, { "@printid",code.printid} },
|
|
|
- "u_configure_codemxbom.pid", outputFields, 0,0,resultList);
|
|
|
+ DbSqlHelper.SelectJoin(cmd, selectStr,null,null,"u_configure_codemxbom.pid", outputFields, 0, 0, resultList);
|
|
|
|
|
|
- foreach(var item in resultList)
|
|
|
- {
|
|
|
- mxlist.Add(InitSoftBedMxFromBom(item, code.has_type.Value));
|
|
|
- }
|
|
|
- }
|
|
|
+ foreach (var item in resultList)
|
|
|
+ {
|
|
|
+ mxlist.Add(InitSoftBedMxFromBom(item, item.has_type));
|
|
|
+ }
|
|
|
return mxlist;
|
|
|
}
|
|
|
/// <summary>
|
|
|
@@ -295,8 +306,9 @@ namespace JLHHJSvr.Helper
|
|
|
loss_rate = bomItem.sonloss,
|
|
|
cost_price = 0,
|
|
|
cost_amt = 0,
|
|
|
- pzname = bomItem.pzname
|
|
|
- };
|
|
|
+ pzname = bomItem.pzname,
|
|
|
+ pznamemx = bomItem.pznamemx
|
|
|
+ };
|
|
|
return mx;
|
|
|
}
|
|
|
/// <summary>
|
|
|
@@ -1441,18 +1453,15 @@ namespace JLHHJSvr.Helper
|
|
|
}
|
|
|
|
|
|
int nextPrintId = GetNextSoftBedTemplateCodeMxIdV2(pzid);
|
|
|
- byte defaultFlag = HasSoftBedTemplateDefaultCodeMxV2(pzid) ? (byte)0 : (byte)1;
|
|
|
-
|
|
|
var insertMx = new u_configure_codemx()
|
|
|
{
|
|
|
pzid = pzid,
|
|
|
printid = nextPrintId,
|
|
|
pzcodemx = $"{pzcode}_{FormatCode(nextPrintId, 3)}",
|
|
|
namemx = codeMxName,
|
|
|
- ifdft = defaultFlag,
|
|
|
ifuse = 1
|
|
|
};
|
|
|
- DbSqlHelper.Insert(cmd, "u_configure_codemx", null, insertMx, "pzid,printid,pzcodemx,namemx,ifdft,ifuse");
|
|
|
+ DbSqlHelper.Insert(cmd, "u_configure_codemx", null, insertMx, "pzid,printid,pzcodemx,namemx,ifuse");
|
|
|
return nextPrintId;
|
|
|
}
|
|
|
|
|
|
@@ -1611,14 +1620,6 @@ namespace JLHHJSvr.Helper
|
|
|
return Convert.ToInt32(result) + 1;
|
|
|
}
|
|
|
|
|
|
- private bool HasSoftBedTemplateDefaultCodeMxV2(int pzid)
|
|
|
- {
|
|
|
- cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_codemx WHERE pzid = @pzid AND ifdft = 1";
|
|
|
- cmd.Parameters.Clear();
|
|
|
- cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
- return Convert.ToInt32(cmd.ExecuteScalar()) > 0;
|
|
|
- }
|
|
|
-
|
|
|
private int GetNextSoftBedTemplateBomPidV2(int pzid, int printid)
|
|
|
{
|
|
|
cmd.CommandText = @"SELECT ISNULL(MAX(pid),0) FROM u_configure_codemxbom WHERE pzid = @pzid AND printid = @printid";
|