|
@@ -0,0 +1,199 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Data.SqlClient;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using JLHHJSvr.BLL;
|
|
|
+using JLHHJSvr.Com;
|
|
|
+using JLHHJSvr.Com.Model;
|
|
|
+using JLHHJSvr.LJException;
|
|
|
+using JLHHJSvr.Tools;
|
|
|
+using LJLib.DAL.SQL;
|
|
|
+using LJLib.Net.SPI.Server;
|
|
|
+
|
|
|
+namespace JLHHJSvr.Excutor
|
|
|
+{
|
|
|
+ internal sealed class SaveBedNetExcutor : ExcutorBase<SaveBedNetRequest, SaveBedNetResponse>
|
|
|
+ {
|
|
|
+ protected override void ExcuteInternal(SaveBedNetRequest request, object state, SaveBedNetResponse rslt)
|
|
|
+ {
|
|
|
+ var tokendata = BllHelper.GetToken(request.token);
|
|
|
+ if (tokendata == null)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "会话已经中断,请重新登录";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (request.bednet == null)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "缺少主表信息";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(request.bednet.bednettypeid <= 0)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "请选择床网类型";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (request.bednetMx == null || !request.bednetMx.Any())
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "缺少报价明细";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 检查是否填写床网高度
|
|
|
+
|
|
|
+ foreach(var mx in request.bednetMx)
|
|
|
+ {
|
|
|
+ if(mx.bednet_height == null || mx.bednet_height <= 0)
|
|
|
+ {
|
|
|
+ rslt.ErrMsg = "请填写床网高";
|
|
|
+ return;
|
|
|
+ } else
|
|
|
+ {
|
|
|
+ request.bednet.mattress_height = mx.bednet_height;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ using (var con = new SqlConnection(GlobalVar.ConnectionString))
|
|
|
+ using (var cmd = con.CreateCommand())
|
|
|
+ {
|
|
|
+ con.Open();
|
|
|
+
|
|
|
+ // 初始化属性
|
|
|
+ AutoInit.AutoInitS(cmd, request.bednet);
|
|
|
+
|
|
|
+ using (cmd.Transaction = con.BeginTransaction())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var dtNow = DateTime.Now;
|
|
|
+
|
|
|
+ var fields = @"deptid,bednettypeid,mattress_width,mattress_length,mattress_height,if_doublenet,if_doublespring,snake_wire_diameter,
|
|
|
+ snake_wire_mtrl_formula,snake_wire_mtrl_cost,pocket_around_spring_formula,pocket_around_spring_cost,
|
|
|
+ pocket_around_fabrics_formula,pocket_around_fabrics_cost,hard_around_mtrl_formula,hard_around_mtrl_cost,
|
|
|
+ hard_around_hr_formula,hard_around_hr_cost,spring_mtrl_cost,spring_hr_cost,glue_price,glue_mtrl_formula,
|
|
|
+ glue_mtrl_cost,fabrics1_mtrl_formula,fabrics1_mtrl_cost,fabrics2_mtrl_formula,fabrics2_mtrl_cost,
|
|
|
+ if_side_iron,side_iron_lossrate,side_iron_price,side_iron_mtrl_formula,side_iron_mtrl_cost,side_iron_hr_formula,
|
|
|
+ side_iron_hr_cost,cnail_price,cnail_mtrl_formula,cnail_mtrl_cost,cnail_hr_formula,cnail_hr_cost,sponge_mtrlid,
|
|
|
+ sponge_thickness,sponge_price,sponge_mtrl_formula,sponge_mtrl_cost,sponge_hr_formula,sponge_hr_cost,edge_mtrlid,
|
|
|
+ edge_price,edge_mtrl_formula,edge_mtrl_cost,edge_hr_formula,edge_hr_cost,fork_qty,fork_price,fork_mtrl_formula,
|
|
|
+ fork_mtrl_cost,fork_hr_formula,fork_hr_cost,if_rsORwa,rsORwa_price,rsORwa_mtrl_formula,rsORwa_mtrl_cost,rsORwa_hr_formula,
|
|
|
+ rsORwa_hr_cost,if_sponge_drilling,sponge_drilling_hr_formula,sponge_drilling_hr_cost,total_hr_cost,total_mtrl_cost,
|
|
|
+ total_fees_cost,total_cost,createtime,createby,bednetname,spring_mtrl_formula,spring_hr_formula,
|
|
|
+ sponge_mtrl_cost_replace_formula,sponge_hr_cost_replace_formula,edge_mtrl_cost_replace_formula,edge_hr_cost_replace_formula,
|
|
|
+ fork_mtrl_cost_replace_formula,fork_hr_cost_replace_formula,rsORwa_mtrl_cost_replace_formula,rsORwa_hr_cost_replace_formula,
|
|
|
+ sponge_drilling_hr_cost_replace_formula,snake_wire_mtrl_cost_replace_formula,taxrate,taxes,commissionrate,commission,fob,
|
|
|
+ profitrate,nottax_factory_cost,nottax_dept_cost,dept_cost,foreign_cost,extras_cost,dept_profitrate,moneyrate,temp_flag,
|
|
|
+ felt_mtrlid,felt_qty,felt_price,felt_dscrp,felt_mtrl_formula,felt_mtrl_cost,felt_hr_formula,felt_hr_cost,
|
|
|
+ felt_mtrl_cost_replace_formula,felt_hr_cost_replace_formula,extras_cost_dscrp,iffork,ifsaleout,autotype,
|
|
|
+ felt_mtrl_x_cost,felt_hr_x_cost,felt_x_qty,felt_mtrl_x_cost_replace_formula,felt_hr_x_cost_replace_formula,
|
|
|
+ felt_x_mtrlid,sale_point,packtype,packqty,other_rate,transport_type,packmtrl,packet_mtrl_formula,
|
|
|
+ packet_hr_formula,packet_mtrl_cost,packet_hr_cost,packet_mtrl_cost_replace_formula,packet_hr_cost_replace_formula,
|
|
|
+ sponge_height,edge_height,sponge_tc_thickness,sponge_tc_height,sponge_tc_mtrlid,sponge_mtrl_tc_formula,
|
|
|
+ sponge_mtrl_tc_cost,sponge_mtrl_tc_cost_replace_formula,duo_qv_str,spring_weight_formula,side_iron_weight_formula,
|
|
|
+ hard_around_weight_formula,fabrics1_weight_formula,fabrics2_weight_formula,felt_weight_formula,cnail_weight_formula,
|
|
|
+ sponge_weight_formula,sponge_weight_tc_formula,edge_weight_formula,fork_weight_formula,spring_weight_replace_formula,
|
|
|
+ side_iron_weight_replace_formula,hard_around_weight_replace_formula,fabrics1_weight_replace_formula,
|
|
|
+ fabrics2_weight_replace_formula,felt_weight_replace_formula,cnail_weight_replace_formula,sponge_weight_replace_formula,
|
|
|
+ sponge_weight_tc_replace_formula,edge_weight_replace_formula,fork_weight_replace_formula,spring_weight_qty,
|
|
|
+ side_iron_weight_qty,hard_around_weight_qty,fabrics1_weight_qty,fabrics2_weight_qty,felt_weight_qty,cnail_weight_qty,
|
|
|
+ sponge_weight_qty,sponge_weight_tc_qty,edge_weight_qty,fork_weight_qty,sum_weight,if_jb";
|
|
|
+
|
|
|
+ var fieldsMx = @"bednetmxid,bednetid,spring_qty_width,spring_qty_length,bednet_height,wire_mtrlid,springid,if_part,if_15strip,
|
|
|
+ if_pocket_around,pocket_around_springid,pocket_around_row,pocket_around_wire_price,pocket_around_spring_cost,
|
|
|
+ pocket_around_fabrics_cost,if_hard_around,hard_around_springid,hard_around_row,hard_around_wire_price,
|
|
|
+ hard_around_mtrl_cost,hard_around_hr_cost,fabrics1_mtrlid,fabrics1_price,fabrics1_mtrl_cost,fabrics2_mtrlid,
|
|
|
+ fabrics2_price,fabrics2_mtrl_cost,if_side_iron,side_iron_qty,side_iron_mtrl_cost,side_iron_hr_cost,
|
|
|
+ pocket_around_spring_cost_replace_formula,pocket_around_fabrics_cost_replace_formula,hard_around_mtrl_cost_replace_formula,
|
|
|
+ hard_around_hr_cost_replace_formula,fabrics1_mtrl_cost_replace_formula,fabrics2_mtrl_cost_replace_formula,
|
|
|
+ side_iron_mtrl_cost_replace_formula,side_iron_hr_cost_replace_formula,cnail_mtrl_cost_replace_formula,cnail_mtrl_cost,
|
|
|
+ cnail_hr_cost_replace_formula,cnail_hr_cost,glue_mtrl_cost_replace_formula,glue_mtrl_cost,spring_mtrl_cost,spring_hr_cost,
|
|
|
+ spring_mtrl_cost_replace_formula,spring_hr_cost_replace_formula,spring_weight_replace_formula";
|
|
|
+
|
|
|
+ var fieldsMx_spring = @"bednetmx_partid,bednetmxid,springid,spring_qty_width,spring_qty_length,fabrics1_mtrl_cost,spring_mtrl_cost,
|
|
|
+ spring_hr_cost,spring_mtrl_cost_replace_formula,spring_hr_cost_replace_formula,spring_weight_replace_formula";
|
|
|
+
|
|
|
+ if (request.bednet.bednetid <= 0)
|
|
|
+ {
|
|
|
+ //新建
|
|
|
+ fields += ",bednetid,bednetcode";
|
|
|
+
|
|
|
+ request.bednet.bednetid = BllHelper.GetID(cmd, "u_bednet");
|
|
|
+ request.bednet.createtime = dtNow;
|
|
|
+ request.bednet.createby = tokendata.username;
|
|
|
+
|
|
|
+ var nettype = new u_bednet_type() { bednettypeid = request.bednet.bednettypeid };
|
|
|
+ DbSqlHelper.SelectOne(cmd, nettype, "typecode");
|
|
|
+
|
|
|
+ // 编号-年月日+流水
|
|
|
+ request.bednet.bednetcode = $"{nettype.typecode}-{dtNow.ToString("yyyyMMdd")}{(request.bednet.bednetid.Value % 10000).ToString("D4")}";
|
|
|
+
|
|
|
+ DbSqlHelper.Insert(cmd, "u_bednet", null, request.bednet, fields);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //修改
|
|
|
+ foreach (var mx in request.bednetMx)
|
|
|
+ {
|
|
|
+ cmd.CommandText = @"DELETE FROM u_bednetmx_spring WHERE bednetmxid = @bednetmxid";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@bednetmxid", mx.bednetmxid);
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
+ }
|
|
|
+
|
|
|
+ cmd.CommandText = @"DELETE FROM u_bednetmx WHERE bednetid = @bednetid";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ cmd.Parameters.AddWithValue("@bednetid", request.bednet.bednetid);
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
+
|
|
|
+ DbSqlHelper.Update(cmd, "u_bednet", null, request.bednet, "bednetid", fields);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var mx in request.bednetMx)
|
|
|
+ {
|
|
|
+ AutoInit.AutoInitS(cmd, mx);
|
|
|
+
|
|
|
+ mx.bednetid = request.bednet.bednetid;
|
|
|
+ mx.bednetmxid = BllHelper.GetID(cmd, "u_bednetmx");
|
|
|
+
|
|
|
+ DbSqlHelper.Insert(cmd, "u_bednetmx", null, mx, fieldsMx);
|
|
|
+
|
|
|
+ if(request.spring != null && request.spring.Any())
|
|
|
+ {
|
|
|
+ foreach(var spring in request.spring)
|
|
|
+ {
|
|
|
+ AutoInit.AutoInitS(cmd, spring);
|
|
|
+
|
|
|
+ spring.bednetmx_partid = request.bednet.bednetid;
|
|
|
+ spring.bednetmxid = BllHelper.GetID(cmd, "u_bednetmx_spring");
|
|
|
+
|
|
|
+ DbSqlHelper.Insert(cmd, "u_bednetmx_spring", null, spring, fieldsMx_spring);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var hisprice = new u_his_price
|
|
|
+ {
|
|
|
+ bednetid_mattressid = request.bednet.bednetid,
|
|
|
+ typeid = 0,
|
|
|
+ cmpdate = dtNow,
|
|
|
+ cmpemp = tokendata.username,
|
|
|
+ nottax_dept_cost = 0,
|
|
|
+ dept_cost = 0,
|
|
|
+ foreign_cost = 0
|
|
|
+ };
|
|
|
+ var fieldsHs = "bednetid_mattressid, typeid, cmpdate, cmpemp, nottax_dept_cost, dept_cost, foreign_cost";
|
|
|
+ DbSqlHelper.Insert(cmd, "u_his_price", null, hisprice, fieldsHs);
|
|
|
+
|
|
|
+ cmd.Transaction.Commit();
|
|
|
+
|
|
|
+ rslt.bednet = new u_bednet() { bednetid = request.bednet.bednetid, bednetcode = request.bednet.bednetcode };
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ cmd.Transaction.Rollback();
|
|
|
+ rslt.ErrMsg = e.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|