|
@@ -6,7 +6,10 @@ using JLHHJSvr.LJException;
|
|
|
using JLHHJSvr.LJFramework.Tools;
|
|
|
using JLHHJSvr.Tools;
|
|
|
using LJLib.DAL.SQL;
|
|
|
+using NPOI.POIFS.Properties;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
using System;
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data.SqlClient;
|
|
|
using System.Linq;
|
|
@@ -118,8 +121,10 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
string expression = ConvertToEnglishSymbols(mx.formula), use_expression = ConvertToEnglishSymbols(mx.useformula);
|
|
|
|
|
|
+ #region 替换大侧,小侧,V侧高度
|
|
|
expression = InitMxSideReplaceMents(mattress, mx, diancengList, mattersstype, expression);
|
|
|
use_expression = InitMxSideReplaceMents(mattress, mx, diancengList, mattersstype,use_expression);
|
|
|
+ #endregion
|
|
|
|
|
|
#region 替换布料幅宽
|
|
|
//大侧
|
|
@@ -1732,7 +1737,7 @@ namespace JLHHJSvr.Helper
|
|
|
var fieldsHs = "bednetid_mattressid, typeid, cmpdate, cmpemp, nottax_dept_cost, dept_cost, foreign_cost, dannum_cost1, dannum_cost2, dannum_cost3, dannum_cost4,dijia_cost1,dijia_cost2,dijia_cost3,dijia_cost4,fob,cabinet_type,taxrate,commission";
|
|
|
DbSqlHelper.Insert(cmd, "u_his_price", null, hisprice, fieldsHs);
|
|
|
}
|
|
|
- public u_mattress GetMattress(int mattressid)
|
|
|
+ public u_mattress GetMattress(int mattressid,string fields = null)
|
|
|
{
|
|
|
if(mattressid <= 0)
|
|
|
{
|
|
@@ -1740,16 +1745,35 @@ namespace JLHHJSvr.Helper
|
|
|
}
|
|
|
|
|
|
var mattress = new u_mattress() { mattressid = mattressid };
|
|
|
- var fields = @"mattressid,mattressname,deptid,mattresstypeid,mattresscode,mattress_width,mattress_length,mattress_height,packtype,packqty,woodpallettype,old_mtrlname,
|
|
|
+ fields = fields ?? @"mattressid,mattressname,deptid,mattresstypeid,mattresscode,mattress_width,mattress_length,mattress_height,packtype,packqty,woodpallettype,old_mtrlname,
|
|
|
total_hr_cost,total_material_cost,fees_dscrp,total_fees_cost,taxrate,commissionrate,commission,fob,profitrate,profitrate_point,butao_point,chaizhuang_point,
|
|
|
haimian_point,dannum_rate,hrcost,biandaicost,zhizao_amt,guanli_rate,discount,extras_cost,dept_profitrate,dept_profitrate_rangli,moneyrate,mattressrelcode,
|
|
|
flag,auditingrep,auditingdate,createtime,createby,total_cost,nottax_factory_cost,nottax_dept_cost,taxes,dept_cost,foreign_cost,foreign_cost_bz,
|
|
|
- nottax_factory_cost/(dept_profitratedept_profitrate_rangli/100)asdijia_cost,xd_flag,xd_auditingrep,xd_auditingdate,qr_flag,qr_auditingrep,
|
|
|
+ nottax_factory_cost/(dept_profitratedept_profitrate_rangli/100) as dijia_cost,xd_flag,xd_auditingrep,xd_auditingdate,qr_flag,qr_auditingrep,
|
|
|
qr_auditingdate,js1_flag,erp_mtrlcode,erp_cb_updatetime,if_bcp_type,if_zhedie_type,if_w_butao,biandai_qty,other_rate,if_moneyrate,parentid,
|
|
|
if_m_chai,if_z_chai,if_d_chai,if_n_butao,if_m_wbutao_way,s_cover_qty,z_cover_qty,x_cover_qty,s_m_cover_qty,z_m_cover_qty,x_m_cover_qty,cabinet_type,area,diameter,cubage,erp_mtrlcode,erp_mtrlid,dannum_type";
|
|
|
DbSqlHelper.SelectOne(cmd, mattress, fields);
|
|
|
return mattress;
|
|
|
}
|
|
|
+ public List<u_mattress> GetMattressList (int mattressid, string fields)
|
|
|
+ {
|
|
|
+ if (mattressid <= 0)
|
|
|
+ {
|
|
|
+ throw new LJCommonException("查找床垫报价失败,ID错误!");
|
|
|
+ }
|
|
|
+
|
|
|
+ var mattressList = new List<u_mattress>();
|
|
|
+ fields = fields ?? @"mattressid,mattressname,deptid,mattresstypeid,mattresscode,mattress_width,mattress_length,mattress_height,packtype,packqty,woodpallettype,old_mtrlname,
|
|
|
+ total_hr_cost,total_material_cost,fees_dscrp,total_fees_cost,taxrate,commissionrate,commission,fob,profitrate,profitrate_point,butao_point,chaizhuang_point,
|
|
|
+ haimian_point,dannum_rate,hrcost,biandaicost,zhizao_amt,guanli_rate,discount,extras_cost,dept_profitrate,dept_profitrate_rangli,moneyrate,mattressrelcode,
|
|
|
+ flag,auditingrep,auditingdate,createtime,createby,total_cost,nottax_factory_cost,nottax_dept_cost,taxes,dept_cost,foreign_cost,foreign_cost_bz,
|
|
|
+ nottax_factory_cost/(dept_profitratedept_profitrate_rangli/100) as dijia_cost,xd_flag,xd_auditingrep,xd_auditingdate,qr_flag,qr_auditingrep,
|
|
|
+ qr_auditingdate,js1_flag,erp_mtrlcode,erp_cb_updatetime,if_bcp_type,if_zhedie_type,if_w_butao,biandai_qty,other_rate,if_moneyrate,parentid,
|
|
|
+ if_m_chai,if_z_chai,if_d_chai,if_n_butao,if_m_wbutao_way,s_cover_qty,z_cover_qty,x_cover_qty,s_m_cover_qty,z_m_cover_qty,x_m_cover_qty,cabinet_type,area,diameter,cubage,erp_mtrlcode,erp_mtrlid,dannum_type";
|
|
|
+ DbSqlHelper.Select(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "@mattressid", mattressid } }, "createtime", 0, 0, mattressList, null, fields);
|
|
|
+
|
|
|
+ return mattressList;
|
|
|
+ }
|
|
|
public List<u_mattress_mx_mtrl> GetMattressMxMtrl(int mattressid,List<string> extraWhere = null)
|
|
|
{
|
|
|
var mxList = new List<u_mattress_mx_mtrl>();
|
|
@@ -1875,38 +1899,15 @@ namespace JLHHJSvr.Helper
|
|
|
/// </summary>
|
|
|
/// <param name="mattressid"></param>
|
|
|
/// <returns></returns>
|
|
|
- public List<u_mattress> GetMattressSubspecs(int mattressid)
|
|
|
+ public List<u_mattress> GetMattressSubspecs(int mattressid,string fields = null)
|
|
|
{
|
|
|
var list = new List<u_mattress>();
|
|
|
- var outputFields = @"mattressid,mattresscode,mattress_width,mattress_length,mattress_height,mattressname,mattressrelcode,parentid,erp_mtrlid,erp_mtrlcode,erp_configcodetype, erp_mtrlengname, erp_mtrlmode, erp_mtrlname, erp_mtrltype, erp_mtrltypeid, erp_mtrlunit, erp_piccode";
|
|
|
- var selectStr = @"SELECT
|
|
|
- mattressid,
|
|
|
- mattresscode,
|
|
|
- mattress_width,
|
|
|
- mattress_length,
|
|
|
- mattress_height,
|
|
|
- mattressname,
|
|
|
- mattressrelcode,
|
|
|
- parentid,
|
|
|
- erp_mtrlid,
|
|
|
- erp_mtrlcode,
|
|
|
- erp_configcodetype,
|
|
|
- erp_mtrlengname,
|
|
|
- erp_mtrlmode,
|
|
|
- erp_mtrlname,
|
|
|
- erp_mtrltype,
|
|
|
- erp_mtrltypeid,
|
|
|
- erp_mtrlunit,
|
|
|
- erp_piccode
|
|
|
- FROM u_mattress
|
|
|
- ";
|
|
|
+ fields = fields ?? "mattressid,mattresscode,mattress_width,mattress_length,mattress_height,mattressname,mattressrelcode,parentid,erp_mtrlid,erp_mtrlcode,erp_configcodetype, erp_mtrlengname, erp_mtrlmode, erp_mtrlname, erp_mtrltype, erp_mtrltypeid, erp_mtrlunit, erp_piccode";
|
|
|
var whereList = new List<string>();
|
|
|
whereList.Add(@"u_mattress.parentid = @mattressid OR parentid = (
|
|
|
SELECT parentid FROM u_mattress WHERE mattressid = @mattressid and parentid > 0
|
|
|
)");
|
|
|
-
|
|
|
- DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), new Dictionary<string, object>() { { "@mattressid", mattressid } }, "mattressid", outputFields, 0, 0, list);
|
|
|
-
|
|
|
+ DbSqlHelper.Select(cmd, "u_mattress", ListEx.GetWhereStr(whereList), new Dictionary<string, object>() { { "@mattressid", mattressid } }, "mattressid", 0, 0, list, null, fields);
|
|
|
return list;
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -1980,7 +1981,7 @@ namespace JLHHJSvr.Helper
|
|
|
return list;
|
|
|
}
|
|
|
/// <summary>
|
|
|
- /// 保存床垫复制清单
|
|
|
+ /// 床垫报价复制清单
|
|
|
/// </summary>
|
|
|
/// <param name="mattressid"></param>
|
|
|
public void CopyMattressInterface(int cpoyid,int mattressid)
|
|
@@ -2014,8 +2015,8 @@ namespace JLHHJSvr.Helper
|
|
|
FROM u_mattress_interface
|
|
|
WHERE mattressid = @copy_id";
|
|
|
cmd.Parameters.Clear();
|
|
|
- cmd.Parameters.AddWithValue("@mattressid", cpoyid);
|
|
|
- cmd.Parameters.AddWithValue("@copy_id", mattressid);
|
|
|
+ cmd.Parameters.AddWithValue("@mattressid", mattressid);
|
|
|
+ cmd.Parameters.AddWithValue("@copy_id", cpoyid);
|
|
|
cmd.ExecuteNonQuery();
|
|
|
|
|
|
cmd.CommandText = @"INSERT INTO u_mattress_interface_qd (
|
|
@@ -2051,8 +2052,8 @@ namespace JLHHJSvr.Helper
|
|
|
FROM u_mattress_interface_qd
|
|
|
WHERE mattressid = @copy_id";
|
|
|
cmd.Parameters.Clear();
|
|
|
- cmd.Parameters.AddWithValue("@mattressid", cpoyid);
|
|
|
- cmd.Parameters.AddWithValue("@copy_id", mattressid);
|
|
|
+ cmd.Parameters.AddWithValue("@mattressid", mattressid);
|
|
|
+ cmd.Parameters.AddWithValue("@copy_id", cpoyid);
|
|
|
cmd.ExecuteNonQuery();
|
|
|
}
|
|
|
|
|
@@ -2161,7 +2162,7 @@ namespace JLHHJSvr.Helper
|
|
|
}
|
|
|
|
|
|
SaveMattress(mattress_copy, mattressMxMtrlList, mattressMxExtra1List, mattressMxExtra2List, true, mattress.createby);
|
|
|
- CopyMattressInterface(mattress_copy.mattressid, mattress.mattressid);
|
|
|
+ CopyMattressInterface(mattress.mattressid,mattress_copy.mattressid);
|
|
|
|
|
|
var mattressSubspecs = GetMattressSubspecs(mattress.mattressid);
|
|
|
foreach (var sub in mattressSubspecs)
|
|
@@ -2229,7 +2230,7 @@ namespace JLHHJSvr.Helper
|
|
|
submattress_copy.xd_flag = 0;
|
|
|
|
|
|
SaveMattress(submattress_copy, mattressMxList, mattressMxExtra1, mattressMxExtra2, true, mattress.createby);
|
|
|
- CopyMattressInterface(submattress_copy.mattressid, sub.mattressid);
|
|
|
+ CopyMattressInterface(sub.mattressid,submattress_copy.mattressid);
|
|
|
}
|
|
|
|
|
|
foreach (var mx in mxlist)
|
|
@@ -2278,7 +2279,6 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
|
|
|
AutoUpdateBcp(mattressid);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public void MattressCalculateCost(u_mattress mattress, List<u_mattress_mx_mtrl> mattressMx, List<u_mattress_mx_extra> extraProcesses, List<u_mattress_mx_extra> extraCosts)
|
|
@@ -2308,7 +2308,6 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
if (i == 1)
|
|
|
{
|
|
|
-
|
|
|
_mattress.dijia_cost1 = nottax_value;
|
|
|
}
|
|
|
else if (i == 2)
|
|
@@ -2810,6 +2809,328 @@ namespace JLHHJSvr.Helper
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+
|
|
|
+ #region 方法优化
|
|
|
+ /// <summary>
|
|
|
+ /// 床垫报价保存
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mattress"></param>
|
|
|
+ /// <param name="ifErp"></param>
|
|
|
+ public void SaveMattressPro(u_mattress mattress,bool ifErp = false)
|
|
|
+ {
|
|
|
+ var fields = @"mattressname, deptid, mattresscode, mattresstypeid, mattress_width, mattress_length, mattress_height, packtype, packqty, woodpallettype, total_hr_cost,
|
|
|
+ total_material_cost, fees_dscrp, total_fees_cost, total_cost, taxrate, taxes, commissionrate, commission, fob, profitrate, dept_profitrate,
|
|
|
+ moneyrate, nottax_factory_cost, nottax_dept_cost, foreign_cost, diameter, area, cabinet_type, hrcost, biandaicost,
|
|
|
+ mattressrelcode, other_rate, flag, dept_profitrate_rangli, profitrate_point, if_moneyrate, discount, if_m_chai, if_z_chai, if_d_chai, if_n_butao,
|
|
|
+ if_w_butao, if_m_wbutao_way, s_cover_qty, z_cover_qty, x_cover_qty, biandai_qty, s_m_cover_qty, z_m_cover_qty, x_m_cover_qty, chaizhuang_point,
|
|
|
+ haimian_point, if_zhedie_type, qr_auditingrep, qr_auditingdate, if_bcp_type, zhizao_amt, foreign_cost_bz, cubage, extras_cost, extras_cost_dscrp,
|
|
|
+ parentid, flag, xd_flag, dannum_type,dannum_cost1,dannum_cost2, dannum_cost3, dannum_cost4, dijia_cost1,dijia_cost2,dijia_cost3,dijia_cost4";
|
|
|
+ var fieldsMx = "mattressmxid,mattressid,formulaid,formula,replace_formula,if_success,priceunit,shrinkage,mtrlid,price,gram_weight,cloth_width,if_inputqty,qty ,costamt,if_areaprice,thickness,chastr,xu,useqty,useformula,replace_useformula,gydscrp,mattress_width,mattress_length";
|
|
|
+ var fieldsExtra = "mattressmxid,mattressid, extraid, extramxid, extraname, price, qty, dscrp, mtrlid";
|
|
|
+
|
|
|
+ mattress.qr_auditingdate = context.opdate;
|
|
|
+ mattress.qr_auditingrep = context.tokendata.username;
|
|
|
+
|
|
|
+ if (ifErp)
|
|
|
+ {
|
|
|
+ fields += ",erp_mtrlcode,erp_mtrlid,erp_configcodetype, erp_mtrlengname, erp_mtrlmode, erp_mtrlname, erp_mtrltype, erp_mtrltypeid, erp_mtrlunit, erp_piccode";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mattress.mattressid <= 0)
|
|
|
+ {
|
|
|
+ // 新建
|
|
|
+ AutoInit.AutoInitS(mattress);
|
|
|
+ //
|
|
|
+ mattress.createtime = context.opdate;
|
|
|
+ if (mattress.parentid == null || mattress.parentid == 0) mattress.createby = context.tokendata.username;
|
|
|
+
|
|
|
+ mattress.mattressid = BllHelper.GetID(cmd, "u_mattress");
|
|
|
+ fields += ",mattressid, createtime, createby";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(mattress.mattresscode))
|
|
|
+ {
|
|
|
+ var mattresstype = new u_mattress_type() { mattresstypeid = mattress.mattresstypeid };
|
|
|
+ DbSqlHelper.SelectOne(cmd, mattresstype, "typecode");
|
|
|
+
|
|
|
+ mattress.mattresscode = $"{mattresstype.typecode}-{context.opdate.ToString("yyyyMMdd")}{(mattress.mattressid % 10000).ToString("D4")}";
|
|
|
+ }
|
|
|
+
|
|
|
+ DbSqlHelper.Insert(cmd, "u_mattress", null, mattress, fields);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 修改
|
|
|
+ AutoInit.AutoInitS(mattress);
|
|
|
+ //
|
|
|
+ DbSqlHelper.Update(cmd, "u_mattress", null, mattress, "mattressid", fields);
|
|
|
+ DeleteMattress(mattress.mattressid);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 插入明细内容
|
|
|
+ if (mattress.mxList != null && mattress.mxList.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in mattress.mxList)
|
|
|
+ {
|
|
|
+ AutoInit.AutoInitS(cmd, item);
|
|
|
+
|
|
|
+ item.mattressid = mattress.mattressid;
|
|
|
+ if (item.mattressmxid == null || item.mattressmxid <= 0)
|
|
|
+ {
|
|
|
+ item.mattressmxid = BllHelper.GetID(cmd, "u_mattress_mx_mtrl");
|
|
|
+ }
|
|
|
+
|
|
|
+ DbSqlHelper.Insert(cmd, "u_mattress_mx_mtrl", null, item, fieldsMx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 插入特殊工艺
|
|
|
+ if (mattress.extraList != null && mattress.extraList.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in mattress.extraList)
|
|
|
+ {
|
|
|
+ AutoInit.AutoInitS(cmd, item);
|
|
|
+
|
|
|
+ item.mattressid = mattress.mattressid;
|
|
|
+ item.mattressmxid = BllHelper.GetID(cmd, "u_mattress_mx_extra");
|
|
|
+
|
|
|
+ DbSqlHelper.Insert(cmd, "u_mattress_mx_extra", null, item, fieldsExtra);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 特殊费用
|
|
|
+ if (mattress.extraCostList != null && mattress.extraCostList.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in mattress.extraCostList)
|
|
|
+ {
|
|
|
+ AutoInit.AutoInitS(cmd, item);
|
|
|
+
|
|
|
+ item.mattressid = mattress.mattressid;
|
|
|
+ item.mattressmxid = BllHelper.GetID(cmd, "u_mattress_mx_extra");
|
|
|
+
|
|
|
+ DbSqlHelper.Insert(cmd, "u_mattress_mx_extra", null, item, fieldsExtra);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新计价历史
|
|
|
+ var hisprice = new u_his_price
|
|
|
+ {
|
|
|
+ bednetid_mattressid = mattress.mattressid,
|
|
|
+ typeid = 1,
|
|
|
+ cmpdate = context.opdate,
|
|
|
+ cmpemp = context.tokendata.username,
|
|
|
+ nottax_dept_cost = mattress.nottax_dept_cost,
|
|
|
+ dept_cost = mattress.dept_cost,
|
|
|
+ foreign_cost = mattress.foreign_cost,
|
|
|
+ dannum_cost1 = mattress.dannum_cost1,
|
|
|
+ dannum_cost2 = mattress.dannum_cost2,
|
|
|
+ dannum_cost3 = mattress.dannum_cost3,
|
|
|
+ dannum_cost4 = mattress.dannum_cost4,
|
|
|
+ dijia_cost1 = mattress.dijia_cost1,
|
|
|
+ dijia_cost2 = mattress.dijia_cost2,
|
|
|
+ dijia_cost3 = mattress.dijia_cost3,
|
|
|
+ dijia_cost4 = mattress.dijia_cost4,
|
|
|
+ fob = mattress.fob,
|
|
|
+ cabinet_type = mattress.cabinet_type,
|
|
|
+ taxrate = mattress.taxrate,
|
|
|
+ commission = mattress.commission
|
|
|
+ };
|
|
|
+ var fieldsHs = "bednetid_mattressid, typeid, cmpdate, cmpemp, nottax_dept_cost, dept_cost, foreign_cost, dannum_cost1, dannum_cost2, dannum_cost3, dannum_cost4,dijia_cost1,dijia_cost2,dijia_cost3,dijia_cost4,fob,cabinet_type,taxrate,commission";
|
|
|
+ DbSqlHelper.Insert(cmd, "u_his_price", null, hisprice, fieldsHs);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理子规格
|
|
|
+ */
|
|
|
+ ProcessSubSpecs(mattress, ifErp);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 初始化子规格
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="parent">主规格</param>
|
|
|
+ /// <param name="subspecsList">副规格</param>
|
|
|
+ public void InitMattressSubSpecs(u_mattress parent, u_mattress child)
|
|
|
+ {
|
|
|
+ var bedNetHelper = GetHelper<BedNetHelper>(cmd, context);
|
|
|
+ // 处理副规格的明细内容
|
|
|
+ foreach (var childMx in child.mxList)
|
|
|
+ {
|
|
|
+ var bednetIndex = 0; // 床网索引
|
|
|
+ var ifSubspecsIndex = 0; // 垫层主副规格物料索引
|
|
|
+ // 副规格床网自动匹配/新增逻辑
|
|
|
+ if (childMx.formulatype == 99 && childMx.mtrlid > 0)
|
|
|
+ {
|
|
|
+ bednetIndex++;
|
|
|
+ var oBednet = new u_bednet();
|
|
|
+ var _bednet = bedNetHelper.GetBedNet(childMx.mtrlid.Value);
|
|
|
+ var _bednetMx = bedNetHelper.GetBedNetMxList(childMx.mtrlid.Value);
|
|
|
+ var _bednetSpring = bedNetHelper.GetBedNetSpringList(childMx.mtrlid.Value);
|
|
|
+
|
|
|
+ // 20250714 副规格的床网,不匹配查找,直接新建
|
|
|
+ oBednet = _bednet;
|
|
|
+ oBednet.bednetid = 0;
|
|
|
+
|
|
|
+ oBednet.mattress_width = child.mattress_width;
|
|
|
+ oBednet.mattress_length = child.mattress_length;
|
|
|
+ if (child.DynamicFields != null && child.DynamicFields.Count > 0)
|
|
|
+ {
|
|
|
+ child.DynamicFields.TryGetValue($"spring_qty_width_{bednetIndex}", out var _spring_qty_width);
|
|
|
+ child.DynamicFields.TryGetValue($"spring_qty_length_{bednetIndex}", out var _spring_qty_length);
|
|
|
+
|
|
|
+ _bednetMx[0].spring_qty_width = Convert.ToInt32(_spring_qty_width);
|
|
|
+ _bednetMx[0].spring_qty_length = Convert.ToInt32(_spring_qty_length);
|
|
|
+
|
|
|
+ if (!child.DynamicFields.TryGetValue($"bednet_fork_qty_{bednetIndex}", out var _bednet_fork_qty))
|
|
|
+ {
|
|
|
+ _bednet_fork_qty = _bednet.fork_qty;
|
|
|
+ }
|
|
|
+
|
|
|
+ oBednet.fork_qty = Convert.ToDecimal(_bednet_fork_qty);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 袋装网,多个分区时,重新分配弹簧
|
|
|
+ bedNetHelper.GetSpringListQty(oBednet, _bednetMx[0], ref _bednetSpring);
|
|
|
+ bedNetHelper.SaveBedNet(oBednet, _bednetMx, _bednetSpring);
|
|
|
+
|
|
|
+ childMx.mtrlid = oBednet.bednetid;
|
|
|
+ childMx.mtrlname = $"{oBednet.typename} {oBednet.bednetcode} {oBednet.mattress_width}*{oBednet.mattress_length}*{oBednet.mattress_height}";
|
|
|
+ childMx.price = oBednet.nottax_factory_cost;
|
|
|
+ childMx.qty = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 垫层改动逻辑
|
|
|
+ if (childMx.formulatype == 1 && childMx.mtrlid > 0)
|
|
|
+ {
|
|
|
+ // 规格长/宽,按比例缩放
|
|
|
+ if (childMx.mattress_width > 0)
|
|
|
+ {
|
|
|
+ childMx.mattress_width = (int)Math.Floor((decimal)childMx.mattress_width * (Convert.ToDecimal(child.mattress_width) / (decimal)parent.mattress_width));
|
|
|
+ }
|
|
|
+ if (childMx.mattress_length > 0)
|
|
|
+ {
|
|
|
+ childMx.mattress_length = (int)Math.Floor((decimal)childMx.mattress_length * (Convert.ToDecimal(child.mattress_length) / (decimal)parent.mattress_length));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 副规格-垫层物料替换
|
|
|
+ if (childMx.if_subspecs == 1 && child.DynamicFields.TryGetValue($"cushions_subspecs_{ifSubspecsIndex}", out var cushions_subspecs))
|
|
|
+ {
|
|
|
+ ifSubspecsIndex++;
|
|
|
+ childMx.mtrlid = Convert.ToInt32(cushions_subspecs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 内布套 / 顶部裥棉逻辑
|
|
|
+ if ((childMx.formulatype == 101 || childMx.formulatype == 102 || childMx.formulatype == 103) && childMx.mtrlid > 0 && (childMx.mattress_width > 0 || childMx.mattress_length > 0))
|
|
|
+ {
|
|
|
+ childMx.mattress_width += child.mattress_width - parent.mattress_width;
|
|
|
+ childMx.mattress_length += child.mattress_length - parent.mattress_length;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 子规格保存
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mattress"></param>
|
|
|
+ /// <param name="ifErp"></param>
|
|
|
+ private void ProcessSubSpecs(u_mattress mattress, bool ifErp)
|
|
|
+ {
|
|
|
+ if (mattress.subspecsList == null) return;
|
|
|
+
|
|
|
+ var existing = GetMattressSubspecs(mattress.mattressid, "mattressid") ?? new List<u_mattress>();
|
|
|
+
|
|
|
+ var oldIdSet = new HashSet<int>(existing.Select(x => x.mattressid));
|
|
|
+ var newIdSet = new HashSet<int>(mattress.subspecsList.Where(x => x.mattressid != 0).Select(x => x.mattressid));
|
|
|
+ var toUpdate = mattress.subspecsList.Where(x => oldIdSet.Contains(x.mattressid)).ToList();
|
|
|
+ var toInsert = mattress.subspecsList.Where(x => x.mattressid == 0).ToList();
|
|
|
+ var toDelete = existing.Where(x => !newIdSet.Contains(x.mattressid)).ToList();
|
|
|
+
|
|
|
+ toDelete.ForEach(x => DeleteMattress(x.mattressid, true));
|
|
|
+
|
|
|
+ var subspecsList = new List<u_mattress>();
|
|
|
+
|
|
|
+ foreach (var child in toInsert)
|
|
|
+ {
|
|
|
+ var copy = CreateSubSpecClone(mattress, child);
|
|
|
+ subspecsList.Add(copy);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var child in toUpdate)
|
|
|
+ {
|
|
|
+ child.mxList = GetMattressMxMtrl(child.mattressid);
|
|
|
+ child.extraList = GetMattressMxExtra(child.mattressid, 1);
|
|
|
+ child.extraCostList = GetMattressMxExtra(child.mattressid, 2);
|
|
|
+ subspecsList.Add(child);
|
|
|
+ }
|
|
|
+
|
|
|
+ subspecsList.Sort((a, b) =>
|
|
|
+ {
|
|
|
+ int cmp = a.mattress_width.Value.CompareTo(b.mattress_width);
|
|
|
+ return cmp != 0 ? cmp : a.mattress_length.Value.CompareTo(b.mattress_length);
|
|
|
+ });
|
|
|
+
|
|
|
+ foreach (var child in subspecsList)
|
|
|
+ {
|
|
|
+ InitMattressSubSpecs(mattress, child);
|
|
|
+ SaveMattressPro(child, ifErp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 子规格复制逻辑
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="parent"></param>
|
|
|
+ /// <param name="child"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private u_mattress CreateSubSpecClone(u_mattress parent, u_mattress child)
|
|
|
+ {
|
|
|
+ var clone = ObjectHelper.DeepCopy(parent);
|
|
|
+ clone.parentid = parent.mattressid;
|
|
|
+ clone.createby = parent.createby;
|
|
|
+ clone.mattressid = child.mattressid;
|
|
|
+ clone.mattresscode = child.mattresscode;
|
|
|
+ clone.subspecsList = child.subspecsList;
|
|
|
+ clone.mattress_width = child.mattress_width;
|
|
|
+ clone.mattress_length = child.mattress_length;
|
|
|
+ clone.mattress_height = child.mattress_height;
|
|
|
+ clone.DynamicFields = child.DynamicFields;
|
|
|
+ clone.mxList = parent.mxList?.Select(mx =>
|
|
|
+ {
|
|
|
+ var mxClone = ObjectHelper.DeepCopy(mx);
|
|
|
+ mxClone.mattressid = 0;
|
|
|
+ mxClone.mattressmxid = 0;
|
|
|
+ return mxClone;
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
+ return clone;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除床垫报价
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mattressid"></param>
|
|
|
+ /// <param name="isDelMain"></param>
|
|
|
+ public void DeleteMattress(int mattressid, bool isDelMain = false)
|
|
|
+ {
|
|
|
+ // 删除所有明细
|
|
|
+ cmd.CommandText = @"DELETE u_mattress_mx_mtrl WHERE mattressid = @mattressid";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@mattressid", mattressid);
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
+
|
|
|
+ // 删除所有额外费用明细
|
|
|
+ cmd.CommandText = @"DELETE u_mattress_mx_extra WHERE mattressid = @mattressid";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@mattressid", mattressid);
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
+
|
|
|
+ // 删除主表
|
|
|
+ if(isDelMain)
|
|
|
+ {
|
|
|
+ cmd.CommandText = @"DELETE u_mattress WHERE mattressid = @mattressid";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@mattressid", mattressid);
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region 公式计算通用方法
|
|
|
private void AddKeyValue(string key, object value, bool isReplace = true)
|
|
|
{
|
|
@@ -2923,7 +3244,7 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
var new_replacements = new Dictionary<string, object>();
|
|
|
|
|
|
- foreach (Match match in matches)
|
|
|
+ foreach (System.Text.RegularExpressions.Match match in matches)
|
|
|
{
|
|
|
if (replacements.TryGetValue(match.Value, out object value2))
|
|
|
{
|