|
@@ -95,30 +95,23 @@ namespace JLHHJSvr.Helper
|
|
// 换料清单
|
|
// 换料清单
|
|
var bomList = GetSoftBedMxBomList(codeMxList);
|
|
var bomList = GetSoftBedMxBomList(codeMxList);
|
|
// 排除不存在配置的物料
|
|
// 排除不存在配置的物料
|
|
- var skipList = new List<int>();
|
|
|
|
- var mxMtrlIds = mxList.Select(t => t.mtrlid).ToList();
|
|
|
|
- if (mxMtrlIds.Count > 0)
|
|
|
|
- {
|
|
|
|
- cmd.CommandText = $@"SELECT mtrlid FROM u_configure_codemxbom WHERE mtrlid NOT IN {ListEx.getString(mxMtrlIds)}";
|
|
|
|
- cmd.Parameters.Clear();
|
|
|
|
- using (var reader = cmd.ExecuteReader())
|
|
|
|
- {
|
|
|
|
- while (reader.Read())
|
|
|
|
- {
|
|
|
|
- skipList.Add(Convert.ToInt32(reader["mtrlid"]));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //var skipList = new List<int>();
|
|
|
|
+ //var mxMtrlIds = mxList.Select(t => t.mtrlid).ToList();
|
|
|
|
+ //if (mxMtrlIds.Count > 0)
|
|
|
|
+ //{
|
|
|
|
+ // cmd.CommandText = $@"SELECT mtrlid FROM u_configure_codemxbom WHERE mtrlid NOT IN {ListEx.getString(mxMtrlIds)}";
|
|
|
|
+ // cmd.Parameters.Clear();
|
|
|
|
+ // using (var reader = cmd.ExecuteReader())
|
|
|
|
+ // {
|
|
|
|
+ // while (reader.Read())
|
|
|
|
+ // {
|
|
|
|
+ // skipList.Add(Convert.ToInt32(reader["mtrlid"]));
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
|
|
foreach (var mx in mxList)
|
|
foreach (var mx in mxList)
|
|
{
|
|
{
|
|
- if(skipList.Contains(mx.mtrlid))
|
|
|
|
- {
|
|
|
|
- mx.printid = newList.Count + 1;
|
|
|
|
- newList.Add(mx);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (mx.pzid > 0)
|
|
if (mx.pzid > 0)
|
|
{
|
|
{
|
|
// 部件
|
|
// 部件
|
|
@@ -170,7 +163,7 @@ namespace JLHHJSvr.Helper
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (pzid > 1) throw new LJCommonException($"换料失败,原因:{contfigtypename}的{mx.mtrlname}存在多个清单,但没有部件!");
|
|
|
|
|
|
+ if (cnt > 1) throw new LJCommonException($"换料失败,原因:{contfigtypename}的{mx.mtrlname}存在多个清单,但没有部件!");
|
|
|
|
|
|
var tmp_bomList = bomList.FindAll(t => t.pzid == pzid);
|
|
var tmp_bomList = bomList.FindAll(t => t.pzid == pzid);
|
|
if (tmp_bomList.Count > 0)
|
|
if (tmp_bomList.Count > 0)
|
|
@@ -193,6 +186,7 @@ namespace JLHHJSvr.Helper
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (newList.Count <= 0) newList.AddRange(bomList);
|
|
return newList;
|
|
return newList;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -206,8 +200,8 @@ namespace JLHHJSvr.Helper
|
|
foreach(var code in codeList)
|
|
foreach(var code in codeList)
|
|
{
|
|
{
|
|
var resultList = new List<u_configure_codemxbom>();
|
|
var resultList = new List<u_configure_codemxbom>();
|
|
- var outputFields = @"pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,cost,cost_emp,cost_date,sonloss,sonloss_formula,
|
|
|
|
- sondecloss,sondecloss_formula,deptid_scll,default_length,default_width,default_qty,mtrlcode,mtrlname,mtrlmode,unit,
|
|
|
|
|
|
+ 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";
|
|
mtrlsectype,zxmtrlmode,usermtrlmode,price";
|
|
var selectStr = @"SELECT u_configure_codemxbom.pzid
|
|
var selectStr = @"SELECT u_configure_codemxbom.pzid
|
|
,u_configure_codemxbom.printid
|
|
,u_configure_codemxbom.printid
|
|
@@ -219,13 +213,10 @@ namespace JLHHJSvr.Helper
|
|
,u_configure_codemxbom.profit_rate
|
|
,u_configure_codemxbom.profit_rate
|
|
,u_configure_codemxbom.realqty
|
|
,u_configure_codemxbom.realqty
|
|
,u_configure_codemxbom.cost
|
|
,u_configure_codemxbom.cost
|
|
- ,u_configure_codemxbom.cost_emp
|
|
|
|
- ,u_configure_codemxbom.cost_date
|
|
|
|
,u_configure_codemxbom.sonloss
|
|
,u_configure_codemxbom.sonloss
|
|
,u_configure_codemxbom.sonloss_formula
|
|
,u_configure_codemxbom.sonloss_formula
|
|
,u_configure_codemxbom.sondecloss
|
|
,u_configure_codemxbom.sondecloss
|
|
,u_configure_codemxbom.sondecloss_formula
|
|
,u_configure_codemxbom.sondecloss_formula
|
|
- ,u_configure_codemxbom.deptid_scll
|
|
|
|
,u_configure_codemxbom.default_length
|
|
,u_configure_codemxbom.default_length
|
|
,u_configure_codemxbom.default_width
|
|
,u_configure_codemxbom.default_width
|
|
,u_configure_codemxbom.default_qty
|
|
,u_configure_codemxbom.default_qty
|
|
@@ -367,6 +358,54 @@ namespace JLHHJSvr.Helper
|
|
var _softbed = GetSoftBed(softbed.softbed_id, "softbed_id,softbed_code,version,update_emp");
|
|
var _softbed = GetSoftBed(softbed.softbed_id, "softbed_id,softbed_code,version,update_emp");
|
|
if (_softbed.version != softbed.version) throw new LJCommonException($"单据:{_softbed.softbed_code}已被{_softbed.update_emp}修改,请重新加载最新数据再操作!");
|
|
if (_softbed.version != softbed.version) throw new LJCommonException($"单据:{_softbed.softbed_code}已被{_softbed.update_emp}修改,请重新加载最新数据再操作!");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if(softbed.softbed_id > 0 && softbed.is_template != 0)
|
|
|
|
+ {
|
|
|
|
+ //
|
|
|
|
+ var configureList = GetSoftBedConfigureName(softbed);
|
|
|
|
+ var bomSet = new Dictionary<int,List<u_configure_codemxbom>>();
|
|
|
|
+
|
|
|
|
+ foreach(var configure in configureList)
|
|
|
|
+ {
|
|
|
|
+ cmd.CommandText = @"SELECT u_configure_code.pzid
|
|
|
|
+ ,u_configure_codemxbom.mtrlid
|
|
|
|
+ ,LTRIM(RTRIM(u_configure_type.contfigtypename))
|
|
|
|
+ ,u_configure_type.contfigtypeid
|
|
|
|
+ FROM u_configure_codemxbom
|
|
|
|
+ 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_configure_type ON u_configure_code.typeid = u_configure_type.contfigtypeid
|
|
|
|
+ WHERE LTRIM(RTRIM(u_configure_type.contfigtypename)) = @contfigtypename";
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
+ cmd.Parameters.AddWithValue("@contfigtypename", configure.Value.contfigtypename);
|
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
|
+ {
|
|
|
|
+ while (reader.Read())
|
|
|
|
+ {
|
|
|
|
+ if (!bomSet.ContainsKey(configure.Key)) bomSet.Add(configure.Key, new List<u_configure_codemxbom>());
|
|
|
|
+
|
|
|
|
+ bomSet[configure.Key].Add(new u_configure_codemxbom()
|
|
|
|
+ {
|
|
|
|
+ pzid = Convert.ToInt32(reader["pzid"]),
|
|
|
|
+ mtrlid = Convert.ToInt32(reader["mtrlid"]),
|
|
|
|
+ typeid = Convert.ToInt32(reader["contfigtypeid"]),
|
|
|
|
+ has_type = configure.Key
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach (var mx in softbed.mxList)
|
|
|
|
+ {
|
|
|
|
+ if(!bomSet.TryGetValue(mx.has_type, out var bomList))
|
|
|
|
+ {
|
|
|
|
+ throw new LJCommonException($"保存失败,原因:{configureList[mx.has_type].contfigtypename}没有设置物料清单");
|
|
|
|
+ }
|
|
|
|
+ var cnt = bomList.Where(t => t.has_type == mx.has_type && t.mtrlid == mx.mtrlid).Count();
|
|
|
|
+ if (cnt > 1) throw new LJCommonException($"保存失败,原因:{configureList[mx.has_type].contfigtypename}的{mx.mtrlname}存在多个清单,但没有设置部件!");
|
|
|
|
+ else if (cnt == 0) throw new LJCommonException($"保存失败,原因:{configureList[mx.has_type].contfigtypename}的{mx.mtrlname}不存在于物料清单中,请检查!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 新建软床报价模板
|
|
/// 新建软床报价模板
|
|
@@ -382,45 +421,9 @@ namespace JLHHJSvr.Helper
|
|
}
|
|
}
|
|
|
|
|
|
string prefix = $"{softbed.softbed_code}|";
|
|
string prefix = $"{softbed.softbed_code}|";
|
|
- var configureList = new List<u_configure_type>();
|
|
|
|
- if(softbed.has_headboard == 1)
|
|
|
|
- {
|
|
|
|
- configureList.Add(new u_configure_type()
|
|
|
|
- {
|
|
|
|
- contfigtypeid = 0,
|
|
|
|
- contfigtypename = $"{prefix}床头",
|
|
|
|
- contfigtype = 0,
|
|
|
|
- usechflag = 1,
|
|
|
|
- flag = 0
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ var configureList = GetSoftBedConfigureName(softbed).Values.ToList();
|
|
|
|
|
|
- if(softbed.has_bedframe == 1)
|
|
|
|
- {
|
|
|
|
- configureList.Add(new u_configure_type()
|
|
|
|
- {
|
|
|
|
- contfigtypeid = 0,
|
|
|
|
- contfigtypename = $"{prefix}床架",
|
|
|
|
- contfigtype = 0,
|
|
|
|
- usechflag = 1,
|
|
|
|
- flag = 0
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (softbed.has_nightstand == 1)
|
|
|
|
- {
|
|
|
|
- configureList.Add(new u_configure_type()
|
|
|
|
- {
|
|
|
|
- contfigtypeid = 0,
|
|
|
|
- contfigtypename = $"{prefix}床头柜",
|
|
|
|
- contfigtype = 0,
|
|
|
|
- usechflag = 1,
|
|
|
|
- flag = 0
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- var baseInfoHelper = GetHelper<BasicInfoHelper>(cmd, context);
|
|
|
|
|
|
+ var baseInfoHelper = GetHelper<BasicInfoHelper>(cmd, context);
|
|
foreach(var configure in configureList)
|
|
foreach(var configure in configureList)
|
|
{
|
|
{
|
|
// 判断是否已存在
|
|
// 判断是否已存在
|
|
@@ -457,6 +460,53 @@ namespace JLHHJSvr.Helper
|
|
DbSqlHelper.Update(cmd, "u_configure_codemx", null, codeMx, "pzid,printid", "ifdft");
|
|
DbSqlHelper.Update(cmd, "u_configure_codemx", null, codeMx, "pzid,printid", "ifdft");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 返回软床报价相关配置名
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="softbed"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private Dictionary<byte, u_configure_type> GetSoftBedConfigureName(u_softbed softbed)
|
|
|
|
+ {
|
|
|
|
+ var dict = new Dictionary<byte, u_configure_type>();
|
|
|
|
+ string prefix = $"{softbed.softbed_code}|";
|
|
|
|
+ if (softbed.has_headboard == 1)
|
|
|
|
+ {
|
|
|
|
+ dict.Add(1, new u_configure_type()
|
|
|
|
+ {
|
|
|
|
+ contfigtypeid = 0,
|
|
|
|
+ contfigtypename = $"{prefix}床头",
|
|
|
|
+ contfigtype = 0,
|
|
|
|
+ usechflag = 1,
|
|
|
|
+ flag = 0
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (softbed.has_nightstand == 1)
|
|
|
|
+ {
|
|
|
|
+ dict.Add(2, new u_configure_type()
|
|
|
|
+ {
|
|
|
|
+ contfigtypeid = 0,
|
|
|
|
+ contfigtypename = $"{prefix}床头柜",
|
|
|
|
+ contfigtype = 0,
|
|
|
|
+ usechflag = 1,
|
|
|
|
+ flag = 0
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (softbed.has_bedframe == 1)
|
|
|
|
+ {
|
|
|
|
+ dict.Add(4,new u_configure_type()
|
|
|
|
+ {
|
|
|
|
+ contfigtypeid = 0,
|
|
|
|
+ contfigtypename = $"{prefix}床架",
|
|
|
|
+ contfigtype = 0,
|
|
|
|
+ usechflag = 1,
|
|
|
|
+ flag = 0
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return dict;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 获取软床报价配置
|
|
/// 获取软床报价配置
|
|
@@ -669,15 +719,19 @@ namespace JLHHJSvr.Helper
|
|
// 总人力成本
|
|
// 总人力成本
|
|
total_hr_cost += 0;
|
|
total_hr_cost += 0;
|
|
}
|
|
}
|
|
- softbed.total_mtrl_cost = total_mtrl_cost;
|
|
|
|
- softbed.total_hr_cost = total_hr_cost;
|
|
|
|
- softbed.total_cost = formula.GetFormulaItem("【车间成本】").value;
|
|
|
|
-
|
|
|
|
- softbed.nottax_factory_cost = formula.GetFormulaItem("【不含税出厂价】").value;
|
|
|
|
- softbed.nottax_dept_cost = formula.GetFormulaItem("【部门不含税价】").value;
|
|
|
|
- softbed.dept_cost = formula.GetFormulaItem("【部门含税价】").value;
|
|
|
|
- softbed.taxes = formula.GetFormulaItem("【税金】").value;
|
|
|
|
- softbed.foreign_cost = formula.GetFormulaItem("【外币价】").value;
|
|
|
|
|
|
+
|
|
|
|
+ if(softbed.mxList != null && softbed.mxList.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ softbed.total_mtrl_cost = total_mtrl_cost;
|
|
|
|
+ softbed.total_hr_cost = total_hr_cost;
|
|
|
|
+ softbed.total_cost = formula.GetFormulaItem("【车间成本】").value;
|
|
|
|
+
|
|
|
|
+ softbed.nottax_factory_cost = formula.GetFormulaItem("【不含税出厂价】").value;
|
|
|
|
+ softbed.nottax_dept_cost = formula.GetFormulaItem("【部门不含税价】").value;
|
|
|
|
+ softbed.dept_cost = formula.GetFormulaItem("【部门含税价】").value;
|
|
|
|
+ softbed.taxes = formula.GetFormulaItem("【税金】").value;
|
|
|
|
+ softbed.foreign_cost = formula.GetFormulaItem("【外币价】").value;
|
|
|
|
+ }
|
|
//formula.CalculateAll();
|
|
//formula.CalculateAll();
|
|
}
|
|
}
|
|
|
|
|