|
@@ -1,6 +1,7 @@
|
|
|
using DirectService.Tools;
|
|
|
using JLHHJSvr.BLL;
|
|
|
using JLHHJSvr.Com.Model;
|
|
|
+using JLHHJSvr.Excutor;
|
|
|
using JLHHJSvr.LJException;
|
|
|
using JLHHJSvr.Tools;
|
|
|
using LJLib.DAL.SQL;
|
|
@@ -42,36 +43,38 @@ namespace JLHHJSvr.Helper
|
|
|
/// <param name="mxlist"></param>
|
|
|
public List<u_softbed_mx> GetSoftBedMxList(int billid,string fields = null)
|
|
|
{
|
|
|
- fields = fields ?? @"softbed_id,printid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
|
+ 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,pzmxname";
|
|
|
var mxlist = new List<u_softbed_mx>();
|
|
|
|
|
|
var selectStr = @"SELECT u_softbed_mx.softbed_id
|
|
|
- ,u_softbed_mx.printid
|
|
|
- ,u_softbed_mx.pzid
|
|
|
- ,u_softbed_mx.mtrlid
|
|
|
- ,u_softbed_mx.mtrlname
|
|
|
- ,u_softbed_mx.mtrlcode
|
|
|
- ,u_softbed_mx.mtrlmode
|
|
|
- ,u_softbed_mx.unit
|
|
|
- ,u_softbed_mx.has_type
|
|
|
- ,u_softbed_mx.allow_edit
|
|
|
- ,u_softbed_mx.cutting_length
|
|
|
- ,u_softbed_mx.cutting_width
|
|
|
- ,u_softbed_mx.cutting_qty
|
|
|
- ,u_softbed_mx.useqty
|
|
|
- ,u_softbed_mx.use_formula
|
|
|
- ,u_softbed_mx.use_formula_str
|
|
|
- ,u_softbed_mx.actual_useqty
|
|
|
- ,u_softbed_mx.loss_rate
|
|
|
- ,u_softbed_mx.price
|
|
|
- ,u_softbed_mx.price_formula
|
|
|
- ,u_softbed_mx.price_formula_str
|
|
|
- ,u_softbed_mx.cost_price
|
|
|
- ,u_softbed_mx.cost_amt
|
|
|
- ,u_configure_code.name AS pzname
|
|
|
- ,u_configure_codemx.namemx AS pzmxname
|
|
|
- FROM u_softbed_mx";
|
|
|
+ ,u_softbed_mx.printid
|
|
|
+ ,u_softbed_mx.formulaid
|
|
|
+ ,u_softbed_mx.pzid
|
|
|
+ ,u_softbed_mx.mtrlid
|
|
|
+ ,u_softbed_mx.mtrlname
|
|
|
+ ,u_softbed_mx.mtrlcode
|
|
|
+ ,u_softbed_mx.mtrlmode
|
|
|
+ ,u_softbed_mx.unit
|
|
|
+ ,u_softbed_mx.has_type
|
|
|
+ ,u_softbed_mx.allow_edit
|
|
|
+ ,u_softbed_mx.cutting_length
|
|
|
+ ,u_softbed_mx.cutting_width
|
|
|
+ ,u_softbed_mx.cutting_qty
|
|
|
+ ,u_softbed_mx.useqty
|
|
|
+ ,u_softbed_mx.use_formula
|
|
|
+ ,u_softbed_mx.use_formula_str
|
|
|
+ ,u_softbed_mx.actual_useqty
|
|
|
+ ,u_softbed_mx.loss_rate
|
|
|
+ ,u_softbed_mx.price
|
|
|
+ ,u_softbed_mx.price_formula
|
|
|
+ ,u_softbed_mx.price_formula_str
|
|
|
+ ,u_softbed_mx.cost_price
|
|
|
+ ,u_softbed_mx.cost_amt
|
|
|
+ ,u_configure_code.name AS pzname
|
|
|
+ FROM u_softbed_mx
|
|
|
+ LEFT JOIN u_configure_code ON u_softbed_mx.pzid = u_configure_code.pzid
|
|
|
+ ";
|
|
|
|
|
|
DbSqlHelper.SelectJoin(cmd, selectStr, "softbed_id = @billid", new Dictionary<string, object>() { { "@billid", billid } }, "printid", fields, 0, 0, mxlist);
|
|
|
|
|
@@ -305,6 +308,29 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
if (cnt > 0) continue;
|
|
|
baseInfoHelper.SaveConfigureType(configure);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成标准选配项值ifdft
|
|
|
+ if(softbed.codeMxList != null && softbed.codeMxList.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var codeMx in softbed.codeMxList)
|
|
|
+ {
|
|
|
+ if (codeMx.pzid == 0) continue;
|
|
|
+ // 判断是否有标准
|
|
|
+ cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_codemx WHERE pzid = @pzid AND ifdft = 1";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
|
|
|
+ if(Convert.ToInt32(cmd.ExecuteScalar()) > 0)
|
|
|
+ {
|
|
|
+ cmd.CommandText = @"UPDATE u_configure_codemx SET ifdft = 0 WHERE pzid = @pzid AND ifdft = 1";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
+ }
|
|
|
+
|
|
|
+ codeMx.ifdft = 1;
|
|
|
+ DbSqlHelper.Update(cmd, "u_configure_codemx", null, codeMx, "pzid,printid", "ifdft");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
public List<u_configure_type> GetSoftBedConfigureList(u_softbed softbed)
|
|
@@ -537,31 +563,56 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
private void InitReplaceMents(u_softbed softbed)
|
|
|
{
|
|
|
- //AddKeyValue("不含税出厂价", "【车间成本】*(【工厂利润率】+【外销加点】)",0);
|
|
|
- //AddKeyValue("部门不含税价", "【不含税出厂价】/【部门利润率】/( 1 - (【佣金点数】- 1))*【额外点数】", 0);
|
|
|
- //AddKeyValue("税金", "【部门不含税价】* (【税率】-1)", 0);
|
|
|
- //AddKeyValue("部门含税价", "【部门不含税价】*【税率】", 0);
|
|
|
- //AddKeyValue("外币价", "【部门含税价】/【汇率】", 0);
|
|
|
-
|
|
|
- //// 初始变量
|
|
|
- //AddKeyValue("部门利润率", string.Empty,softbed.dept_profitrate);
|
|
|
- //AddKeyValue("佣金点数", string.Empty, softbed.commission);
|
|
|
- //AddKeyValue("额外点数", string.Empty, softbed.other_rate);
|
|
|
- //AddKeyValue("额外费用", string.Empty, softbed.extras_cost);
|
|
|
- ////AddKeyValue("FOB", softbed.fob);
|
|
|
- //AddKeyValue("汇率", string.Empty, softbed.moneyrate);
|
|
|
- //AddKeyValue("税率", string.Empty, softbed.taxrate);
|
|
|
+ // 公式变量
|
|
|
+ formula.AddFormulaItem("不含税出厂价", "【车间成本】*(【工厂利润率】+【外销加点】)");
|
|
|
+ formula.AddFormulaItem("部门不含税价", "【不含税出厂价】/【部门利润率】/( 1 - (【佣金点数】- 1))*【额外点数】+【FOB】");
|
|
|
+ formula.AddFormulaItem("部门含税价", "【部门不含税价】*【税率】");
|
|
|
+ formula.AddFormulaItem("税金", "【部门不含税价】* (【税率】-1)");
|
|
|
+ formula.AddFormulaItem("外币价", "【部门含税价】/【汇率】");
|
|
|
+
|
|
|
+ // 常量变量
|
|
|
+ formula.AddFormulaItem("部门利润率", softbed.dept_profitrate);
|
|
|
+ formula.AddFormulaItem("佣金点数", softbed.commission);
|
|
|
+ formula.AddFormulaItem("额外点数", softbed.other_rate);
|
|
|
+ formula.AddFormulaItem("额外费用", softbed.extras_cost);
|
|
|
+ formula.AddFormulaItem("FOB", 0);
|
|
|
+ formula.AddFormulaItem("汇率", softbed.moneyrate);
|
|
|
+ formula.AddFormulaItem("税率", softbed.taxrate);
|
|
|
}
|
|
|
|
|
|
private void InitMxReplaceMents(u_softbed softbed,u_softbed_mx mx)
|
|
|
{
|
|
|
- //AddKeyValue("下料长", string.Empty,mx.cutting_length);
|
|
|
- //AddKeyValue("下料宽", string.Empty, mx.cutting_width);
|
|
|
- //AddKeyValue("下料数量", string.Empty, mx.cutting_qty);
|
|
|
- //AddKeyValue("用料量", string.Empty, mx.useqty);
|
|
|
- //AddKeyValue("损耗率", string.Empty, mx.loss_rate);
|
|
|
- //AddKeyValue("材料单价", string.Empty, mx.price);
|
|
|
- //AddKeyValue("成本单价", string.Empty, mx.cost_price);
|
|
|
+ // 默认公式变量
|
|
|
+ formula.AddFormulaItem("实际用量", "【用料量】*【1 + 损耗率】");
|
|
|
+ formula.AddFormulaItem("成本金额", "【实际用量】 * 【成本单价】");
|
|
|
+
|
|
|
+ // 常量变量
|
|
|
+ formula.AddFormulaItem("下料长", mx.cutting_length);
|
|
|
+ formula.AddFormulaItem("下料宽", mx.cutting_width);
|
|
|
+ formula.AddFormulaItem("下料数量", mx.cutting_qty);
|
|
|
+ formula.AddFormulaItem("用料量", mx.useqty);
|
|
|
+ formula.AddFormulaItem("损耗率", mx.loss_rate);
|
|
|
+ formula.AddFormulaItem("材料单价", mx.price);
|
|
|
+
|
|
|
+ if(mx.formulaid > 0)
|
|
|
+ {
|
|
|
+ cmd.CommandText = @"SELECT u_softbed_formula.formulaid
|
|
|
+ ,u_softbed_formula.formulaname
|
|
|
+ ,u_softbed_formula.use_formula
|
|
|
+ ,u_softbed_formula.price_formula
|
|
|
+ FROM u_softbed_formula
|
|
|
+ WHERE formulaid = @formulaid";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@formulaid", mx.formulaid);
|
|
|
+ using(var reader = cmd.ExecuteReader())
|
|
|
+ {
|
|
|
+ if(reader.Read())
|
|
|
+ {
|
|
|
+ formula.AddFormulaItem("实际用量", Convert.ToString(reader["use_formula"]));
|
|
|
+ formula.AddFormulaItem("成本单价", Convert.ToString(reader["price_formula"]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#region 通用公式
|