Browse Source

后台:增加床垫床网保存当计算失败逻辑依然能保存

chen_yjin 5 months ago
parent
commit
796b95f916

+ 36 - 0
JLHHJSvr/Com/GetComputeBednet.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.Com.Model;
+using LJLib.Net.SPI.Com;
+
+namespace JLHHJSvr.Com
+{
+    public sealed class GetComputeBednetRequest : ILJRequest<GetComputeBednetResponse>
+    {
+        public string GetApiName()
+        {
+            return "GetComputeBednet";
+        }
+        public string token { get; set; }
+        /// <summary>
+        /// 半成品信息:主表
+        /// </summary>
+        public u_bednet bednet { get; set; }
+        public List<u_bednetmx> bednetMx { get; set; }
+        public List<u_bednetmx_spring> spring { get; set; }
+    }
+
+    public sealed class GetComputeBednetResponse : LJResponse
+    {
+        public u_bednet bednet { get; set; }
+        public List<Replacement> replace { get; set; }
+    }
+
+    public struct Replacement
+    {
+        public string label { get; set; }
+        public object value { get; set; }
+    }
+}

+ 2 - 0
JLHHJSvr/Com/SaveBedNet.cs

@@ -25,5 +25,7 @@ namespace JLHHJSvr.Com
     public sealed class SaveBedNetResponse : LJResponse
     public sealed class SaveBedNetResponse : LJResponse
     {
     {
         public u_bednet bednet { get; set; }
         public u_bednet bednet { get; set; }
+
+        public string message { get; set; }
     }
     }
 }
 }

+ 1 - 0
JLHHJSvr/Com/SaveMattress.cs

@@ -30,5 +30,6 @@ namespace JLHHJSvr.Com
     public sealed class SaveMattressResponse : LJResponse
     public sealed class SaveMattressResponse : LJResponse
     {
     {
         public int mattressid { get; set; }
         public int mattressid { get; set; }
+        public string message { get; set; }
     }
     }
 }
 }

+ 36 - 0
JLHHJSvr/DataStore/web_bednet_choose.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<select>
+	<selectstr>
+		select
+		u_bednet.bednetid,
+		u_bednet.bednetcode,
+		u_bednet_type.typename,
+		u_bednet.total_cost,
+		u_bednet.mattress_width,
+		u_bednet.mattress_length,
+		u_bednet.mattress_height,
+		u_bednet.createtime,
+		u_bednet.bednetname,
+		u_bednet.nottax_factory_cost
+		from u_bednet inner join u_bednet_type on
+		u_bednet.bednettypeid = u_bednet_type.bednettypeid
+	</selectstr>
+	<where>
+		<when notnull="@arg_deptid">
+			u_bednet.deptid=@arg_deptid
+		</when>
+		<when notnull="@arg_search">
+			u_bednet.bednetname like '%'+ @arg_search + '%' OR u_bednet.bednetcode like '%'+ @arg_search + '%' OR u_bednet.bednetid like '%'+ @arg_search + '%'
+		</when>
+	</where>
+	<displayfields>
+		<field field="pid" compute="getrow()">序</field>
+		<field field="bednetname" table="u_bednet">床网名称</field>
+		<field field="bednetcode" table="u_bednet">报价唯一码</field>
+		<field field="typename" table="u_bednet_type">类别</field>
+		<field field="mattress_width" table="u_bednet">床垫宽</field>
+		<field field="mattress_length" table="u_bednet">床垫长</field>
+		<field field="mattress_height" table="u_bednet">床垫高</field>
+		<field field="createtime" table="u_bednet" datatype="datetime">登记时间</field>
+	</displayfields>
+</select>

+ 95 - 0
JLHHJSvr/Excutor/GetComputeBednetExcutor.cs

@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using DirectService.Tools;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.Helper;
+using JLHHJSvr.LJException;
+using JLHHJSvr.LJFramework.Tools;
+using JLHHJSvr.Tools;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class GetComputeBednetExcutor : ExcutorBase<GetComputeBednetRequest, GetComputeBednetResponse>
+    {
+        Dictionary<string, object> replacements = new Dictionary<string, object>();
+
+        protected override void ExcuteInternal(GetComputeBednetRequest request, object state, GetComputeBednetResponse 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);
+
+                foreach(var mx in request.bednetMx)
+                {
+                    AutoInit.AutoInitS(cmd, mx);
+                }
+
+                foreach (var mx in request.spring)
+                {
+                    AutoInit.AutoInitS(cmd, mx);
+                }
+
+                var helper = HelperBase.GetHelper<BedNetHelper>(cmd,new HelperBase.Context() { tokendata = tokendata});
+
+                helper.CalCulateFormula(request.bednet, request.bednetMx, request.spring);
+                var replacements = helper.Replacements;
+                rslt.replace = new List<Replacement>();
+
+                // 访问和遍历列表
+                foreach (var item in helper.Replacements)
+                {
+                    rslt.replace.Add(new Replacement { label = item.Key, value = item.Value });
+                }
+
+                rslt.bednet = request.bednet;
+            }
+        }
+    }
+}

+ 9 - 1
JLHHJSvr/Excutor/SaveBedNetExcutor.cs

@@ -78,7 +78,15 @@ namespace JLHHJSvr.Excutor
 
 
                 var helper = HelperBase.GetHelper<BedNetHelper>(cmd,new HelperBase.Context() { tokendata = tokendata});
                 var helper = HelperBase.GetHelper<BedNetHelper>(cmd,new HelperBase.Context() { tokendata = tokendata});
 
 
-                helper.CalCulateFormula(request.bednet, request.bednetMx, request.spring);
+                try
+                {
+                    helper.CalCulateFormula(request.bednet, request.bednetMx, request.spring);
+                }
+                catch (Exception e)
+                {
+                    rslt.message = e.Message;
+                }
+
 
 
                 using (cmd.Transaction = con.BeginTransaction())
                 using (cmd.Transaction = con.BeginTransaction())
                 {
                 {

+ 8 - 0
JLHHJSvr/Excutor/SaveMattressExcutor.cs

@@ -50,6 +50,14 @@ namespace JLHHJSvr.Excutor
                     try
                     try
                     {
                     {
                         helper.CalCulateFormula(request.mattress, request.mattressMx);
                         helper.CalCulateFormula(request.mattress, request.mattressMx);
+                    }
+                    catch (Exception e)
+                    {
+                        rslt.message = e.Message;
+                    }
+
+                    try
+                    {
 
 
                         helper.SaveMattress(request.mattress, request.mattressMx);
                         helper.SaveMattress(request.mattress, request.mattressMx);
                         
                         

+ 3 - 0
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -163,6 +163,9 @@ namespace JLHHJSvr
                 excutorManager.AddMap("SaveBedNet", typeof(SaveBedNetRequest), new SaveBedNetExcutor());// 保存床网报价
                 excutorManager.AddMap("SaveBedNet", typeof(SaveBedNetRequest), new SaveBedNetExcutor());// 保存床网报价
                 excutorManager.AddMap("DeleteBedNet", typeof(DeleteBedNetRequest), new DeleteBedNetExcutor());// 删除床网报价
                 excutorManager.AddMap("DeleteBedNet", typeof(DeleteBedNetRequest), new DeleteBedNetExcutor());// 删除床网报价
                 excutorManager.AddMap("AuditBedNet", typeof(AuditBedNetRequest), new AuditBedNetExcutor());// 审核床网报价
                 excutorManager.AddMap("AuditBedNet", typeof(AuditBedNetRequest), new AuditBedNetExcutor());// 审核床网报价
+
+                //excutorManager.AddMap("GetComputeMattress", typeof(GetComputeMattressRequest), new GetComputeMattressExcutor());// 计算床垫报价
+                excutorManager.AddMap("GetComputeBednet", typeof(GetComputeBednetRequest), new GetComputeBednetExcutor());// 计算床网报价
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {

+ 7 - 2
JLHHJSvr/Helper/BedNetHelper.cs

@@ -20,6 +20,11 @@ namespace JLHHJSvr.Helper
         private Dictionary<string, object> replacements = new Dictionary<string, object>();
         private Dictionary<string, object> replacements = new Dictionary<string, object>();
         private Dictionary<string, string> formula_replacements = new Dictionary<string, string>();
         private Dictionary<string, string> formula_replacements = new Dictionary<string, string>();
 
 
+        public Dictionary<string, object> Replacements
+        {
+            get { return replacements; }
+        }
+
         public void CalCulateFormula(u_bednet bednet, List<u_bednetmx> mxlist, List<u_bednetmx_spring> springList)
         public void CalCulateFormula(u_bednet bednet, List<u_bednetmx> mxlist, List<u_bednetmx_spring> springList)
         {
         {
             InitBedNet(bednet);
             InitBedNet(bednet);
@@ -1527,8 +1532,8 @@ namespace JLHHJSvr.Helper
                 {
                 {
                     foreach (var spring in springList)
                     foreach (var spring in springList)
                     {
                     {
-                        spring.bednetmx_partid = bednet.bednetid;
-                        spring.bednetmxid = BllHelper.GetID(cmd, "u_bednetmx_spring");
+                        spring.bednetmxid = mx.bednetmxid;
+                        spring.bednetmx_partid = BllHelper.GetID(cmd, "u_bednetmx_spring");
 
 
                         DbSqlHelper.Insert(cmd, "u_bednetmx_spring", null, spring, fieldsMx_spring);
                         DbSqlHelper.Insert(cmd, "u_bednetmx_spring", null, spring, fieldsMx_spring);
                     }
                     }

+ 2 - 2
JLHHJSvr/Helper/MattressHelper.cs

@@ -565,9 +565,9 @@ namespace JLHHJSvr.Helper
 
 
                 if (mattress.packqty == 0) throw new LJCommonException("请填写卷包直径!");
                 if (mattress.packqty == 0) throw new LJCommonException("请填写卷包直径!");
 
 
-                var bzList = mxlist.Where(t => t.formulatype == 3 && t.formulakind == 19).ToList();
+                var _bzList = mxlist.Where(t => t.formulatype == 3 && t.formulakind == 19).ToList();
 
 
-                foreach(var bz in bzList)
+                foreach(var bz in _bzList)
                 {
                 {
                     if (bz.mtrlname.IndexOf("箱") > -1) { 
                     if (bz.mtrlname.IndexOf("箱") > -1) { 
                         mattress.loading_type = "卷包(进箱)";
                         mattress.loading_type = "卷包(进箱)";

+ 2 - 0
JLHHJSvr/JLHHJSvr.csproj

@@ -137,6 +137,7 @@
     <Compile Include="Com\Model\u_shrinkage.cs" />
     <Compile Include="Com\Model\u_shrinkage.cs" />
     <Compile Include="Com\Model\u_spring.cs" />
     <Compile Include="Com\Model\u_spring.cs" />
     <Compile Include="Com\Model\u_workmanship_add.cs" />
     <Compile Include="Com\Model\u_workmanship_add.cs" />
+    <Compile Include="Com\GetComputeBednet.cs" />
     <Compile Include="Com\SaveBedNet.cs" />
     <Compile Include="Com\SaveBedNet.cs" />
     <Compile Include="Com\SaveBedNetArea.cs" />
     <Compile Include="Com\SaveBedNetArea.cs" />
     <Compile Include="Com\SaveBedNetType.cs" />
     <Compile Include="Com\SaveBedNetType.cs" />
@@ -259,6 +260,7 @@
     <Compile Include="Excutor\ModPasswordExcutor.cs" />
     <Compile Include="Excutor\ModPasswordExcutor.cs" />
     <Compile Include="Excutor\PostFileExcutor.cs" />
     <Compile Include="Excutor\PostFileExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetAreaExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetAreaExcutor.cs" />
+    <Compile Include="Excutor\GetComputeBednetExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetTypeExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetTypeExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetVarExcutor.cs" />
     <Compile Include="Excutor\SaveBedNetVarExcutor.cs" />