|
|
@@ -5,16 +5,20 @@ using JLHHJSvr.Excutor;
|
|
|
using JLHHJSvr.LJException;
|
|
|
using JLHHJSvr.Tools;
|
|
|
using LJLib.DAL.SQL;
|
|
|
+using NPOI.HSSF.Record;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Web;
|
|
|
+using System.Web.Configuration;
|
|
|
using static JLHHJSvr.Helper.CacheHelper;
|
|
|
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
|
|
|
|
namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
@@ -45,7 +49,7 @@ namespace JLHHJSvr.Helper
|
|
|
public List<u_softbed_mx> GetSoftBedMxList(int billid,string fields = null)
|
|
|
{
|
|
|
fields = fields ?? @"softbed_id,printid,formulaid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
|
- useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,formulaname";
|
|
|
+ useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,formulaname,parts_type";
|
|
|
var mxlist = new List<u_softbed_mx>();
|
|
|
|
|
|
var selectStr = @"SELECT u_softbed_mx.softbed_id
|
|
|
@@ -72,7 +76,8 @@ namespace JLHHJSvr.Helper
|
|
|
,u_softbed_mx.price_formula_str
|
|
|
,u_softbed_mx.cost_price
|
|
|
,u_softbed_mx.cost_amt
|
|
|
- ,ISNULL(u_configure_code.name,'') AS pzname
|
|
|
+ ,ISNULL(u_configure_code.name,u_softbed_mx.pzname) AS pzname
|
|
|
+ ,u_softbed_mx.parts_type
|
|
|
,ISNULL(u_softbed_formula.formulaname,'') AS formulaname
|
|
|
FROM u_softbed_mx
|
|
|
LEFT JOIN u_configure_code ON u_softbed_mx.pzid = u_configure_code.pzid
|
|
|
@@ -83,109 +88,112 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
return mxlist;
|
|
|
}
|
|
|
- public List<u_softbed_mx> GetChangeSoftBedMxList(int billid,List<u_configure_codemx> codeMxList)
|
|
|
+ public List<u_softbed_mx> GetChangeSoftBedMxList(int billid,List<u_softbed_mx> mxList,List<u_configure_codemx> codeMxList)
|
|
|
{
|
|
|
var newList = new List<u_softbed_mx>();
|
|
|
-
|
|
|
- var softbed = GetSoftBed(billid, "billid,softbed_code,has_headboard,has_nightstand,has_bedframe");
|
|
|
+ var pzid0List = new List<u_softbed_mx>();
|
|
|
+ var softbed = GetSoftBed(billid, "billid,softbed_code,has_headboard,has_nightstand,has_bedframe,is_template,template_id");
|
|
|
if (softbed == null) return newList;
|
|
|
-
|
|
|
- // 物料清单
|
|
|
- var mxList = GetSoftBedMxList(billid);
|
|
|
- // 换料清单
|
|
|
- var bomList = GetSoftBedMxBomList(codeMxList);
|
|
|
- // 排除不存在配置的物料
|
|
|
- //var skipList = new List<int>();
|
|
|
- //var mxMtrlIds = mxList.Select(t => t.mtrlid).ToList();
|
|
|
- //if (mxMtrlIds.Count > 0)
|
|
|
+ // 换料清单
|
|
|
+ var bomList = GetSoftBedMxBomList(codeMxList);
|
|
|
+ // var typeDict = new Dictionary<string, List<u_softbed_mx>>();
|
|
|
+ //foreach(var mx in mxList)
|
|
|
//{
|
|
|
- // 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)
|
|
|
- {
|
|
|
- if (mx.pzid > 0)
|
|
|
- {
|
|
|
- // 部件
|
|
|
- var tmp_bomList = bomList.FindAll(t => t.has_type == mx.has_type && t.pzid == mx.pzid);
|
|
|
- if (tmp_bomList.Count > 0)
|
|
|
- {
|
|
|
- // add
|
|
|
- foreach (var temp in tmp_bomList)
|
|
|
- {
|
|
|
- if (temp.mtrlid == mx.mtrlid)
|
|
|
- {
|
|
|
- mx.printid = newList.Count + 1;
|
|
|
- newList.Add(mx);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- temp.printid = newList.Count + 1;
|
|
|
- newList.Add(temp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // 非部件
|
|
|
- string contfigtypename = string.Empty;
|
|
|
- string prefix = $"{softbed.softbed_code}|";
|
|
|
- if (mx.has_type == 1) contfigtypename = $"{prefix}床头";
|
|
|
- else if (mx.has_type == 2) contfigtypename = $"{prefix}床头柜";
|
|
|
- else contfigtypename = $"{prefix}床架";
|
|
|
+ // var key = $"{mx.has_type}|{mx.pzid}";
|
|
|
+ // if(!typeDict.ContainsKey(key))
|
|
|
+ // {
|
|
|
+ // typeDict.Add(key, new List<u_softbed_mx>());
|
|
|
+ // }
|
|
|
|
|
|
- cmd.CommandText = @"SELECT u_configure_code.pzid
|
|
|
- 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 u_configure_codemxbom.mtrlid = @mtrlid AND LTRIM(RTRIM(u_configure_type.contfigtypename)) = @contfigtypename";
|
|
|
- cmd.Parameters.Clear();
|
|
|
- cmd.Parameters.AddWithValue("@mtrlid",mx.mtrlid);
|
|
|
- cmd.Parameters.AddWithValue("@contfigtypename", contfigtypename);
|
|
|
- int pzid = 0, cnt = 0;
|
|
|
- using(var reader = cmd.ExecuteReader())
|
|
|
- {
|
|
|
- while(reader.Read())
|
|
|
- {
|
|
|
- pzid = Convert.ToInt32(reader["pzid"]);
|
|
|
- cnt++;
|
|
|
- }
|
|
|
- }
|
|
|
+ // typeDict[key].Add(mx);
|
|
|
+
|
|
|
+ // if (mx.pzid == 0) pzid0List.Add(mx);
|
|
|
+ // }
|
|
|
|
|
|
- if (cnt > 1) throw new LJCommonException($"换料失败,原因:{contfigtypename}的{mx.mtrlname}存在多个清单,但没有部件!");
|
|
|
+ // 原Dictionary替换为List<KeyValuePair>,维护键值对的插入顺序
|
|
|
+ var typeList = new List<KeyValuePair<string, List<u_softbed_mx>>>();
|
|
|
+ foreach (var mx in mxList)
|
|
|
+ {
|
|
|
+ var key = $"{mx.has_type}|{mx.pzid}";
|
|
|
+ var existingItem = typeList.FirstOrDefault(kvp => kvp.Key == key);
|
|
|
|
|
|
- var tmp_bomList = bomList.FindAll(t => t.pzid == pzid);
|
|
|
- if (tmp_bomList.Count > 0)
|
|
|
+ if (existingItem.Equals(default(KeyValuePair<string, List<u_softbed_mx>>)))
|
|
|
+ {
|
|
|
+ var newMxList = new List<u_softbed_mx> { mx };
|
|
|
+ typeList.Add(new KeyValuePair<string, List<u_softbed_mx>>(key, newMxList));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ existingItem.Value.Add(mx);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mx.pzid == 0)
|
|
|
+ {
|
|
|
+ pzid0List.Add(mx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var bomDict = new Dictionary<string, List<u_softbed_mx>>();
|
|
|
+ foreach (var bom in bomList)
|
|
|
+ {
|
|
|
+ var key = $"{bom.has_type}|{bom.pzid}";
|
|
|
+ if (!bomDict.ContainsKey(key))
|
|
|
+ {
|
|
|
+ bomDict.Add(key, new List<u_softbed_mx>());
|
|
|
+ }
|
|
|
+ bomDict[key].Add(bom);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 1、模板报价
|
|
|
+ * 2、非模板报价
|
|
|
+ * 仅替换配置,保留其他明细信息
|
|
|
+ * 1、如果明细存在bomList中,证明没有替换,直接添加到newList
|
|
|
+ * 2、如果明细不存在bomList中,证明可能是给替换的(2.1)或者是非部件(即手动添加2.2)
|
|
|
+ */
|
|
|
+ foreach (var kvp in typeList)
|
|
|
+ {
|
|
|
+ if (bomDict.TryGetValue(kvp.Key, out var temp_bomList))
|
|
|
+ {
|
|
|
+ bool isExist = false;
|
|
|
+ foreach (var mx in kvp.Value)
|
|
|
+ {
|
|
|
+ isExist = temp_bomList.FindIndex(t => t.mtrlid == mx.mtrlid) > -1;
|
|
|
+ }
|
|
|
+ if (isExist)
|
|
|
{
|
|
|
- // add
|
|
|
- foreach (var temp in tmp_bomList)
|
|
|
+ // 1
|
|
|
+ foreach (var mx in kvp.Value)
|
|
|
{
|
|
|
- if (temp.mtrlid == mx.mtrlid)
|
|
|
- {
|
|
|
- mx.printid = newList.Count + 1;
|
|
|
- newList.Add(mx);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- temp.printid = newList.Count + 1;
|
|
|
- newList.Add(temp);
|
|
|
- }
|
|
|
+ mx.printid = newList.Count + 1;
|
|
|
+ newList.Add(mx);
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 2.1
|
|
|
+ foreach (var mx in temp_bomList)
|
|
|
+ {
|
|
|
+ mx.printid = newList.Count + 1;
|
|
|
+ newList.Add(mx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bomDict.Remove(kvp.Key);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ // 新增的部件
|
|
|
+ foreach (var item in bomDict)
|
|
|
+ {
|
|
|
+ foreach (var mx in item.Value)
|
|
|
+ {
|
|
|
+ mx.printid = newList.Count + 1;
|
|
|
+ newList.Add(mx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2.2
|
|
|
+ foreach (var mx in pzid0List)
|
|
|
+ {
|
|
|
+ mx.printid = newList.Count + 1;
|
|
|
+ newList.Add(mx);
|
|
|
+ }
|
|
|
if (newList.Count <= 0) newList.AddRange(bomList);
|
|
|
return newList;
|
|
|
}
|
|
|
@@ -202,7 +210,7 @@ namespace JLHHJSvr.Helper
|
|
|
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";
|
|
|
+ mtrlsectype,zxmtrlmode,usermtrlmode,price,pzname";
|
|
|
var selectStr = @"SELECT u_configure_codemxbom.pzid
|
|
|
,u_configure_codemxbom.printid
|
|
|
,u_configure_codemxbom.pid
|
|
|
@@ -228,7 +236,10 @@ namespace JLHHJSvr.Helper
|
|
|
,u_mtrldef.zxmtrlmode
|
|
|
,u_mtrldef.usermtrlmode
|
|
|
,u_erpmtrl_price.price
|
|
|
+ ,u_configure_codemx.namemx AS pzname
|
|
|
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_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,
|
|
|
@@ -272,7 +283,8 @@ namespace JLHHJSvr.Helper
|
|
|
actual_useqty = 0,
|
|
|
loss_rate = bomItem.sonloss,
|
|
|
cost_price = 0,
|
|
|
- cost_amt = 0
|
|
|
+ cost_amt = 0,
|
|
|
+ pzname = bomItem.pzname
|
|
|
};
|
|
|
return mx;
|
|
|
}
|
|
|
@@ -289,18 +301,20 @@ namespace JLHHJSvr.Helper
|
|
|
foreach(var mx in softbed.mxList)
|
|
|
{
|
|
|
AutoInit.AutoInitS(mx);
|
|
|
- }
|
|
|
|
|
|
+ if (mx.has_type != 8) mx.parts_type = string.Empty;
|
|
|
+ else if (string.IsNullOrEmpty(mx.parts_type)) throw new LJCommonException($"明细行:{mx.printid},存在其他配件明细未设置配件类型,请检查!");
|
|
|
+ }
|
|
|
// 计算价格
|
|
|
CalCulateFormula(softbed);
|
|
|
- //
|
|
|
+ //
|
|
|
var dtNow = context.opdate;
|
|
|
var fields = @"softbed_relcode,softbed_name,deptid,mtrlmode,mtrltype,has_headboard,has_nightstand,has_bedframe,is_template,
|
|
|
template_id,template_code,template_name,commission,taxes,taxrate,other_rate,extras_cost,money_type,moneyrate,dscrp,costamt,nottax_factory_cost,nottax_dept_cost,
|
|
|
dept_cost,foreign_cost,total_mtrl_cost,total_hr_cost,total_cost,version";
|
|
|
|
|
|
var mx_fields = @"softbed_id,printid,pzid,formulaid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
|
- useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt";
|
|
|
+ useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,parts_type,pzname";
|
|
|
|
|
|
if(softbed.softbed_id == 0)
|
|
|
{
|
|
|
@@ -406,8 +420,8 @@ namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
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}存在多个清单,但没有设置部件!");
|
|
|
+ //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}不存在于物料清单中,请检查!");
|
|
|
}
|
|
|
}
|
|
|
@@ -542,7 +556,11 @@ namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
// 模版配置获取
|
|
|
int billid = softbed.softbed_id > 0 ? softbed.softbed_id : softbed.template_id;
|
|
|
- var _softbed = GetSoftBed(billid, "softbed_id,softbed_code,has_headboard,has_nightstand,has_bedframe");
|
|
|
+ var _softbed = GetSoftBed(billid, "softbed_id,softbed_code,has_headboard,has_nightstand,has_bedframe,template_id,is_template");
|
|
|
+ if(_softbed.is_template == 0)
|
|
|
+ {
|
|
|
+ _softbed = GetSoftBed(_softbed.template_id, "softbed_code,has_headboard,has_nightstand,has_bedframe");
|
|
|
+ }
|
|
|
string prefix = $"{_softbed.softbed_code}|";
|
|
|
|
|
|
if(_softbed.has_headboard == 1)
|
|
|
@@ -621,26 +639,31 @@ namespace JLHHJSvr.Helper
|
|
|
/// </summary>
|
|
|
/// <param name="softbed"></param>
|
|
|
/// <param name="newId"></param>
|
|
|
- public void CopySoftBed(u_softbed softbed, out int newId)
|
|
|
+ public u_softbed CopySoftBed(u_softbed softbed)
|
|
|
{
|
|
|
- var fields = @"mtrlmode,mtrltype,has_headboard,has_nightstand,has_bedframe,is_template,
|
|
|
- template_id,template_code,template_name,commission,taxes,taxrate,other_rate,extras_cost,moneyrate";
|
|
|
- var softbed_copy = GetSoftBed(softbed.softbed_id, fields);
|
|
|
-
|
|
|
+ var softbed_copy = ObjectHelper.DeepCopy(softbed);
|
|
|
+ softbed_copy.softbed_id = 0;
|
|
|
+ SaveSoftBed(softbed_copy);
|
|
|
|
|
|
- // 判断copy_bedNet.bednetcode是否存在@@字符串,如果存在,则删除@@后面的字符串,包括@@
|
|
|
- if (softbed_copy.softbed_code.IndexOf("@@") > -1)
|
|
|
+ if(softbed_copy.is_template == 1 && softbed.copy_id > 0)
|
|
|
{
|
|
|
- softbed_copy.softbed_code = softbed_copy.softbed_code.Substring(softbed_copy.softbed_code.IndexOf("@@"));
|
|
|
+ // 复制配置到新配置
|
|
|
+ var _softbed = GetSoftBed(softbed.copy_id, "softbed_code,has_headboard,has_nightstand,has_bedframe");
|
|
|
+ if(_softbed.has_headboard == 1 && softbed_copy.has_headboard == 1)
|
|
|
+ {
|
|
|
+ CopyConfigureData($"{_softbed.softbed_code}|床头",$"{softbed_copy.softbed_code}|床头");
|
|
|
+ }
|
|
|
+ if (_softbed.has_nightstand == 1 && softbed_copy.has_nightstand == 1)
|
|
|
+ {
|
|
|
+ CopyConfigureData($"{_softbed.softbed_code}|床头柜", $"{softbed_copy.softbed_code}|床头柜");
|
|
|
+ }
|
|
|
+ if (_softbed.has_bedframe == 1 && softbed_copy.has_bedframe == 1)
|
|
|
+ {
|
|
|
+ CopyConfigureData($"{_softbed.softbed_code}|床架", $"{softbed_copy.softbed_code}|床架");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- softbed_copy.softbed_code += " @@";
|
|
|
- softbed_copy.softbed_code += DateTime.Now.ToString("yyyMMdd_mmhhss");
|
|
|
- softbed_copy.softbed_id = 0;
|
|
|
-
|
|
|
- SaveSoftBed(softbed_copy);
|
|
|
-
|
|
|
- newId = softbed_copy.softbed_id;
|
|
|
+ return softbed_copy;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -847,6 +870,108 @@ namespace JLHHJSvr.Helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private List<string> GetConfigureTypeNameFromBillId(int billid)
|
|
|
+ {
|
|
|
+ var _softbed = GetSoftBed(billid, "softbed_code,has_headboard,has_nightstand,has_bedframe");
|
|
|
+
|
|
|
+ var nameList = new List<string>();
|
|
|
+ string prefix = $"{_softbed.softbed_code}|";
|
|
|
+ if (_softbed.has_headboard == 1)
|
|
|
+ {
|
|
|
+ nameList.Add($"{_softbed.softbed_code}|床头");
|
|
|
+ }
|
|
|
+ if (_softbed.has_nightstand == 1)
|
|
|
+ {
|
|
|
+ nameList.Add($"{_softbed.softbed_code}|床头柜");
|
|
|
+ }
|
|
|
+ if (_softbed.has_bedframe == 1)
|
|
|
+ {
|
|
|
+ nameList.Add($"{_softbed.softbed_code}|床架");
|
|
|
+ }
|
|
|
+
|
|
|
+ return nameList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CopyConfigureData(string SourceName, string TargetName)
|
|
|
+ {
|
|
|
+ var commonHelper = GetHelper<CommonHelper>(cmd, context);
|
|
|
+ var basicInfoHelper = GetHelper<BasicInfoHelper>(cmd, context);
|
|
|
+ // 入参非空验证
|
|
|
+ if (string.IsNullOrWhiteSpace(SourceName))
|
|
|
+ {
|
|
|
+ throw new LJCommonException("源配置名称不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (string.IsNullOrWhiteSpace(TargetName))
|
|
|
+ {
|
|
|
+ throw new LJCommonException("目标配置名称不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ int SourceId = 0, TargetId = 0;
|
|
|
+ cmd.CommandText = @"SELECT contfigtypeid FROM u_configure_type WHERE LTRIM(RTRIM(contfigtypename)) = LTRIM(RTRIM(@SourceName))";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@SourceName", SourceName);
|
|
|
+ using(var reader = cmd.ExecuteReader())
|
|
|
+ {
|
|
|
+ if(reader.Read())
|
|
|
+ {
|
|
|
+ SourceId = Convert.ToInt32(reader["contfigtypeid"]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ cmd.CommandText = @"SELECT contfigtypeid FROM u_configure_type WHERE LTRIM(RTRIM(contfigtypename)) = LTRIM(RTRIM(@TargetName))";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@TargetName", TargetName);
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
+ {
|
|
|
+ if (reader.Read())
|
|
|
+ {
|
|
|
+ TargetId = Convert.ToInt32(reader["contfigtypeid"]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (SourceId == 0) throw new LJCommonException($"源配置名称「{SourceName.Trim()}」未找到对应的结果");
|
|
|
+ if (TargetId == 0) throw new LJCommonException($"目标配置名称「{TargetName.Trim()}」未找到对应的结果");
|
|
|
+ // 部件选配项
|
|
|
+ var codeList = commonHelper.ExecuteDynamicSelectToList<u_configure_code>("web_configure_codelist",new Newtonsoft.Json.Linq.JObject() { { "typeid",SourceId} },0,0);
|
|
|
+ var code_copyList = new List<u_configure_code>();
|
|
|
+ var codeIdMap = new Dictionary<int, int>();
|
|
|
+ foreach(var code in codeList)
|
|
|
+ {
|
|
|
+ var code_copy = ObjectHelper.DeepCopy(code);
|
|
|
+ code_copy.pzid = BllHelper.GetID(cmd, "u_configure_code");
|
|
|
+ code_copy.typeid = TargetId;
|
|
|
+ code_copyList.Add(code_copy);
|
|
|
+
|
|
|
+ if (codeIdMap.ContainsKey(code.pzid.Value)) continue;
|
|
|
+ codeIdMap.Add(code.pzid.Value, code_copy.pzid.Value);
|
|
|
+ //basicInfoHelper.SaveConfigureCode(code_copy);
|
|
|
+ }
|
|
|
+ DbSqlHelper.BulkInsert(cmd, code_copyList, "u_configure_code", null, "typeid,pzid,pzcode,inputtype,name,configtype,ifcross,ifcheck,ifuse,rulestr,ifnum,decnum,maxnum,minnum,pricestr,priceratestr,ifpack,zj_special");
|
|
|
+ // 部件选配值
|
|
|
+ var codeMxList = commonHelper.ExecuteDynamicSelectToList<u_configure_codemx>("web_configure_codemxlist", new Newtonsoft.Json.Linq.JObject() { { "typeid", SourceId } }, 0, 0);
|
|
|
+ var codeMx_copyList = new List<u_configure_codemx>();
|
|
|
+ foreach (var codeMx in codeMxList)
|
|
|
+ {
|
|
|
+ if (!codeIdMap.TryGetValue(codeMx.pzid.Value, out int newId)) continue;
|
|
|
+ var codeMx_copy = ObjectHelper.DeepCopy(codeMx);
|
|
|
+ codeMx_copy.pzid = newId;
|
|
|
+ codeMx_copyList.Add(codeMx_copy);
|
|
|
+ }
|
|
|
+ DbSqlHelper.BulkInsert(cmd, codeMx_copyList, "u_configure_codemx",null, "pzid,printid,pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade");
|
|
|
+ // 部件选配物料清单
|
|
|
+ var codeMxBomList = commonHelper.ExecuteDynamicSelectToList<u_configure_codemxbom>("web_configure_codemxbomlist", new Newtonsoft.Json.Linq.JObject() { { "typeid", SourceId } }, 0, 0);
|
|
|
+ var codeMxBom_copyList = new List<u_configure_codemxbom>();
|
|
|
+ foreach (var codeMxBom in codeMxBomList)
|
|
|
+ {
|
|
|
+ if (!codeIdMap.TryGetValue(codeMxBom.pzid, out int newId)) continue;
|
|
|
+ var codeMxBom_copy = ObjectHelper.DeepCopy(codeMxBom);
|
|
|
+ codeMxBom_copy.pzid = newId;
|
|
|
+ codeMxBom_copyList.Add(codeMxBom_copy);
|
|
|
+ }
|
|
|
+ DbSqlHelper.BulkInsert(cmd, codeMxBom_copyList, "u_configure_codemxbom",null, "pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,sonloss,sonloss_formula,sondecloss,sondecloss_formula,default_length,default_width,default_qty");
|
|
|
+ }
|
|
|
+
|
|
|
#region 通用公式
|
|
|
private CalculateFormula formula = new CalculateFormula();
|
|
|
private string BillKeyWord = "u_softbed";
|