Forráskód Böngészése

床垫清单更新价格信息

chen_yjin 1 hónapja
szülő
commit
7919e1e84a

+ 2 - 0
JLHHJSvr/Com/Model/u_mattress.cs

@@ -168,6 +168,8 @@ namespace JLHHJSvr.Com.Model
         /// </summary>
         public int? spring_qty_length { get; set; }
         public int? mtrltypeid { get; set; }
+        public string bj_mxdscrp { get; set; }
+        public decimal? dijia_cost { get; set; }
         #endregion
     }
 }

+ 24 - 0
JLHHJSvr/Com/UpdateMtrlPrice.cs

@@ -0,0 +1,24 @@
+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 UpdateMtrlPriceRequest : ILJRequest<UpdateMtrlPriceResponse>
+    {
+        public override string GetApiName()
+        {
+            return "UpdateMtrlPrice";
+        }
+        public string token { get; set; }
+        public int mattressid { get; set; }
+    }
+
+    public sealed class UpdateMtrlPriceResponse : LJResponse
+    {
+        public u_mattress mattress { get; set; }
+    }
+}

+ 7 - 1
JLHHJSvr/Excutor/CreatMtrlPfExcutor.cs

@@ -35,7 +35,7 @@ namespace JLHHJSvr.Excutor
                 con.Open();
 
                 var mattress = new u_mattress();
-                if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", request.mattressid } }, mattress, "erp_mtrlid,erp_mtrlcode, erp_mtrlname, erp_mtrlmode, erp_mtrltypeid, erp_mtrltype, erp_mtrlunit, erp_mtrlengname") != 1)
+                if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", request.mattressid } }, mattress, "erp_mtrlid,erp_mtrlcode, erp_mtrlname, erp_mtrlmode, erp_mtrltypeid, erp_mtrltype, erp_mtrlunit, erp_mtrlengname,nottax_factory_cost,dept_profitrate,dept_profitrate_rangli,commission,taxes,fob,extras_cost") != 1)
                 {
                     rslt.ErrMsg = "床垫报价单匹配失败";
                     return;
@@ -48,6 +48,12 @@ namespace JLHHJSvr.Excutor
 
                 if (mattress.erp_mtrlid <= 0)
                 {
+                    var lde_dijia_cost = mattress.nottax_factory_cost / (mattress.dept_profitrate + mattress.dept_profitrate_rangli / 100);
+                    var lde_commission = lde_dijia_cost / (1 - (mattress.commission - 1)) - lde_dijia_cost;
+                    var ls_bj_mxdscrp = "底价:" + lde_dijia_cost.Value.ToString("###0.00") + ",  佣金:" + lde_commission.Value.ToString("###0.00") + ",  税金:" + mattress.taxes.Value.ToString("###0.00") + ",  fob:" + mattress.fob.Value.ToString("###0.00") + ",  最后更新日期:" + DateTime.Today.ToString("yyyy-MM-dd") + "," + mattress.nottax_factory_cost.Value.ToString("###0.00");
+                    mattress.bj_mxdscrp = ls_bj_mxdscrp;
+                    mattress.dijia_cost = lde_dijia_cost;
+
                     var errMsg = l1Helper.SaveMtrldef(mattress);
                     if (!string.IsNullOrEmpty(errMsg))
                     {

+ 106 - 0
JLHHJSvr/Excutor/UpdateMtrlPriceExcutor.cs

@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.Helper;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using Newtonsoft.Json.Linq;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class UpdateMtrlPriceExcutor : ExcutorBase<UpdateMtrlPriceRequest, UpdateMtrlPriceResponse>
+    {
+        Dictionary<string, object> replacements = new Dictionary<string, object>();
+
+        protected override void ExcuteInternal(UpdateMtrlPriceRequest request, object state, UpdateMtrlPriceResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+            if (request.mattressid <= 0)
+            {
+                rslt.ErrMsg = "床垫id参数为空!";
+                return;
+            }
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+
+                var mattress = new u_mattress();
+                if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", request.mattressid } }, mattress, "erp_mtrlid,erp_mtrlcode, erp_mtrlname, erp_mtrlmode, erp_mtrltypeid, erp_mtrltype, erp_mtrlunit, erp_mtrlengname,nottax_factory_cost,dept_profitrate,dept_profitrate_rangli,commission,taxes,fob,extras_cost") != 1)
+                {
+                    rslt.ErrMsg = "床垫报价单匹配失败";
+                    return;
+                }
+
+                var l1Helper = HelperBase.GetHelper<ERPHelper>(cmd);
+                l1Helper.context = new HelperBase.Context() { tokendata = tokendata };
+
+                l1Helper.CheckLogin();
+
+                var lde_dijia_cost = mattress.nottax_factory_cost / (mattress.dept_profitrate + mattress.dept_profitrate_rangli / 100);
+                var lde_commission = lde_dijia_cost / (1 - (mattress.commission - 1)) - lde_dijia_cost;
+                var ls_bj_mxdscrp = "底价:" + lde_dijia_cost.Value.ToString("###0.00") + ",  佣金:" + lde_commission.Value.ToString("###0.00") + ",  税金:" + mattress.taxes.Value.ToString("###0.00") + ",  fob:" + mattress.fob.Value.ToString("###0.00") + ",  最后更新日期:" + DateTime.Today.ToString("yyyy-MM-dd") + "," + mattress.nottax_factory_cost.Value.ToString("###0.00");
+                mattress.bj_mxdscrp = ls_bj_mxdscrp;
+
+                var errMsg = l1Helper.SaveMtrldef(mattress, "bj_mxdscrp");
+                if (!string.IsNullOrEmpty(errMsg))
+                {
+                    rslt.ErrMsg = errMsg;
+                    return;
+                }
+
+                errMsg = l1Helper.UpdateL1Planprice(mattress.erp_mtrlid.Value, mattress.nottax_dept_cost.Value);
+                if (!string.IsNullOrEmpty(errMsg))
+                {
+                    rslt.ErrMsg = errMsg;
+                    return;
+                }
+
+                //更新床网半成品
+                var mattressMx = new u_mattress_mx_mtrl();
+                if (DbSqlHelper.SelectOne(cmd, "u_mattress_mx_mtrl", "erp_mtrlid <> 0 AND mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", request.mattressid } }, mattress, "mtrlid , erp_mtrlid") == 1)
+                {
+                    decimal lde_cost = 0;
+                    var ll_erp_mtrlid = 0;
+
+                    cmd.CommandText = @"select
+                            isnull(total_cost,0)  - 
+                            isnull(sponge_mtrl_cost,0)  -
+                            isnull(felt_mtrl_cost,0)  -
+                            isnull(felt_mtrl_x_cost,0)  -
+                            isnull(packet_mtrl_cost,0)  - 
+                            isnull(packet_hr_cost,0) AS cw_cost
+                        FROM u_bednet WHERE mattressid = @deptid";
+                    cmd.Parameters.Clear();
+                    cmd.Parameters.AddWithValue("@mattressid", mattressMx.mtrlid);
+                    using (var reader = cmd.ExecuteReader())
+                    {
+                        if (reader.Read())
+                        {
+                            lde_cost = Convert.ToDecimal(reader["nottax_factory_cost"]);
+                        }
+                    }
+
+                    errMsg = l1Helper.UpdateL1Planprice(mattressMx.erp_mtrlid.Value, lde_cost);
+                    if (!string.IsNullOrEmpty(errMsg))
+                    {
+                        rslt.ErrMsg = errMsg;
+                        return;
+                    }
+
+                }
+            }
+        }
+
+    }
+}

+ 4 - 0
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -213,6 +213,7 @@ namespace JLHHJSvr
                 excutorManager.AddMap("RefreshMattressInterface", typeof(RefreshMattressInterfaceRequest), new RefreshMattressInterfaceExcutor());// 刷新床垫配置清单
                 excutorManager.AddMap("RefreshMattressInterfaceQd", typeof(RefreshMattressInterfaceQdRequest), new RefreshMattressInterfaceQdExcutor());// 刷新床垫清单
                 excutorManager.AddMap("CreatMtrlPf", typeof(CreatMtrlPfRequest), new CreatMtrlPfExcutor());// 生成L1清单
+                excutorManager.AddMap("UpdateMtrlPrice", typeof(UpdateMtrlPriceRequest), new UpdateMtrlPriceExcutor());// 更新L1计划价
                 excutorManager.AddMap("DelMtrlPf", typeof(CreatMtrlPfRequest), new DelMtrlPfExcutor());// 删除L1清单
 
                 excutorManager.AddMap("GetERPMtrldefList", typeof(GetERPMtrldefListRequest), new GetERPMtrldefListExcutor());// 获取ERP物料资料
@@ -220,6 +221,9 @@ namespace JLHHJSvr
                 excutorManager.AddMap("GetERPWrkGrpList", typeof(GetERPWrkGrpListRequest), new GetERPWrkGrpListExcutor());// 获取工组列表
                 excutorManager.AddMap("GetERPMtrlTypeList", typeof(GetERPMtrlTypeListRequest), new GetERPMtrlTypeListExcutor());// 获取ERP物料类型
                 excutorManager.AddMap("GetMattressInterfaceList", typeof(GetMattressInterfaceListRequest), new GetMattressInterfaceListExcutor());// 获取产品清单明细
+                //excutorManager.AddMap("GetSemiFinishedMxList", typeof(GetSemiFinishedMxListRequest), new GetSemiFinishedMxListExcutor());// 获取产品清单明细
+
+                //excutorManager.AddMap("ImportSpring", typeof(ImportSpringRequest), new ImportSpringExcutor());
             }
             catch (Exception ex)
             {

+ 31 - 3
JLHHJSvr/Helper/ERPHelper.cs

@@ -129,7 +129,7 @@ namespace JLHHJSvr.Helper
         /// </summary>
         /// <param name="mtrl">核价物料资料</param>
         /// <returns>错误信息</returns>
-        public string SaveMtrldef(u_mattress mtrl)
+        public string SaveMtrldef(u_mattress mtrl, string fields = "mtrlname,mtrlmode,mtrltypeid,mtrltype,unit,mtrlengname")
         {
             var errMsg = string.Empty;
 
@@ -146,10 +146,18 @@ namespace JLHHJSvr.Helper
                         ["mtrltypeid"] = mtrl.erp_mtrltypeid,
                         ["mtrltype"] = mtrl.erp_mtrltype,
                         ["unit"] = mtrl.erp_mtrlunit,
-                        ["mtrlengname"] = mtrl.erp_mtrlengname
+                        ["mtrlengname"] = mtrl.erp_mtrlengname,
+                        ["dijia_cost"] = mtrl.dijia_cost, // 底价1
+                        ["dijia_cost2"] = mtrl.dijia_cost, // 底价2
+                        ["dijia_cost3"] = mtrl.dijia_cost, // 底价3
+                        ["fob"] = mtrl.fob, // fob费用
+                        ["taxes"] = mtrl.taxes, // 税金
+                        ["extras_cost"] = mtrl.extras_cost, // 额外费用
+                        ["planprice"] = mtrl.nottax_factory_cost, // 计划价
+                        ["bj_mxdscrp"] = mtrl.bj_mxdscrp
                     }
                 },
-                ["updateFields"] = "mtrlname,mtrlmode,mtrltypeid,mtrltype,unit,mtrlengname"
+                ["updateFields"] = fields
             };
 
             var l1Rslt = DoExecute("SaveMtrldef", JObject.FromObject(l1Req));
@@ -162,5 +170,25 @@ namespace JLHHJSvr.Helper
             }
             return errMsg;
         }
+
+        /// <summary>
+        /// 更新L1计划价 wf_updateL1_planprice
+        /// </summary>
+        /// <param name="mattress"></param>
+        public string UpdateL1Planprice(int erp_mtrlid, decimal value)
+        {
+            var errMsg = string.Empty;
+
+            var l1Req = new JObject()
+            {
+                ["token"] = GlobalVar.ERP_TOKEN,
+                ["mtrlid"] = erp_mtrlid,
+                ["value"] = value,
+            };
+
+            var l1Rslt = DoExecute("UpdateMtrldefPlanPrice", JObject.FromObject(l1Req));
+            errMsg = $"{l1Rslt.GetValue("ErrMsg")}";
+            return errMsg;
+        }
     }
 }

+ 28 - 1
JLHHJSvr/JLHHJSvr.csproj

@@ -35,9 +35,27 @@
     <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.Excel.2.1.1\lib\ICSharpCode.SharpZipLib.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
+    <Reference Include="NPOI, Version=2.1.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.Excel.2.1.1\lib\NPOI.dll</HintPath>
+    </Reference>
+    <Reference Include="NPOI.OOXML, Version=2.1.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.Excel.2.1.1\lib\NPOI.OOXML.dll</HintPath>
+    </Reference>
+    <Reference Include="NPOI.OpenXml4Net, Version=2.1.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.Excel.2.1.1\lib\NPOI.OpenXml4Net.dll</HintPath>
+    </Reference>
+    <Reference Include="NPOI.OpenXmlFormats, Version=2.1.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.Excel.2.1.1\lib\NPOI.OpenXmlFormats.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.configuration" />
     <Reference Include="System.Configuration.Install" />
@@ -81,6 +99,7 @@
     <Compile Include="Com\CommonDynamicSelect.cs" />
     <Compile Include="Com\CopyMattressAudited.cs" />
     <Compile Include="Com\CopyMtrlDef.cs" />
+    <Compile Include="Com\UpdateMtrlPrice.cs" />
     <Compile Include="Com\DelCarList.cs" />
     <Compile Include="Com\DeleteBedNet.cs" />
     <Compile Include="Com\DeleteBedNetArea.cs" />
@@ -108,6 +127,7 @@
     <Compile Include="Com\GetComputeSpring.cs" />
     <Compile Include="Com\GetERPMtrlTypeList.cs" />
     <Compile Include="Com\GetMattressImportDW2.cs" />
+    <Compile Include="Com\GetSemiFinishedMxList.cs" />
     <Compile Include="Com\GetMattressPackagMx.cs" />
     <Compile Include="Com\GetComputeMattress.cs" />
     <Compile Include="Com\GetComputeBednet.cs" />
@@ -123,6 +143,7 @@
     <Compile Include="Com\GetPriceList.cs" />
     <Compile Include="Com\GetSysFuncPwr.cs" />
     <Compile Include="Com\GetFormulaCompute.cs" />
+    <Compile Include="Com\ImportSpring.cs" />
     <Compile Include="Com\MattressJS2Audit.cs" />
     <Compile Include="Com\MattressJSAudit.cs" />
     <Compile Include="Com\MattressYWAudit.cs" />
@@ -260,6 +281,7 @@
     <Compile Include="Excutor\CommonDynamicSelectExcutor.cs" />
     <Compile Include="Excutor\CopyMattressAuditedExcutor.cs" />
     <Compile Include="Excutor\CopyMtrlDefExcutor.cs" />
+    <Compile Include="Excutor\UpdateMtrlPriceExcutor.cs" />
     <Compile Include="Excutor\DelMtrlPfExcutor.cs" />
     <Compile Include="Excutor\DelCarListExcutor.cs" />
     <Compile Include="Excutor\DeleteBedNetAreaExcutor.cs" />
@@ -288,6 +310,7 @@
     <Compile Include="Excutor\GetCarListExcutor.cs" />
     <Compile Include="Excutor\GetComputeSpringExcutor.cs" />
     <Compile Include="Excutor\GetERPMtrlTypeListExcutor.cs" />
+    <Compile Include="Excutor\GetSemiFinishedMxListExcutor.cs" />
     <Compile Include="Excutor\GetMattressPackagMxExcutor.cs" />
     <Compile Include="Excutor\GetMattressImportDW2Excutor.cs" />
     <Compile Include="Excutor\GetComputeMattressExcutor.cs" />
@@ -310,6 +333,7 @@
     <Compile Include="Excutor\GetUserListExcutor.cs" />
     <Compile Include="Excutor\GetUserPowerExcutor.cs" />
     <Compile Include="Excutor\HelloWordExcutor.cs" />
+    <Compile Include="Excutor\ImportSpringExcutor.cs" />
     <Compile Include="Excutor\LoginExcutor.cs" />
     <Compile Include="Excutor\MattressJS2AuditExcutor.cs" />
     <Compile Include="Excutor\MattressJSAuditExcutor.cs" />
@@ -512,6 +536,7 @@
       <DependentUpon>LJInstaller.cs</DependentUpon>
     </EmbeddedResource>
     <None Include="app.config" />
+    <Fakes Include="Fakes\NPOI.fakes" />
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
@@ -523,7 +548,9 @@
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
     </Compile>
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <WCFMetadata Include="Connected Services\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
     <PreBuildEvent>"$(SolutionDir)NetGitTool.exe" /before "$(ProjectDir)"</PreBuildEvent>