From 23c70befcda68f72625e2f71cbeea5fac92b5f33 Mon Sep 17 00:00:00 2001 From: ddlucky Date: Fri, 13 Jan 2023 21:10:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=9A=E9=94=90=E9=92=89=E9=92=89=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E5=85=A5=E5=BA=93=E8=B4=B9=E7=94=A8=E5=85=A5=E8=B4=A6?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DSWeb.Common/DB/Comm.cs | 16 + .../CommMng/Controllers/WorkFlowController.cs | 75 +++- DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs | 1 + .../Areas/MvcShipping/DAL/WMSNew/WMSNewDAL.cs | 174 +++++++- .../MvcShipping/Helper/DingTalkHelper.cs | 415 ++++++++++++++++-- DSWeb/Areas/MvcShipping/Models/WMS/WMS.cs | 13 +- 6 files changed, 627 insertions(+), 67 deletions(-) diff --git a/DSWeb.Common/DB/Comm.cs b/DSWeb.Common/DB/Comm.cs index 069a10ab..83581e3a 100644 --- a/DSWeb.Common/DB/Comm.cs +++ b/DSWeb.Common/DB/Comm.cs @@ -1655,6 +1655,9 @@ namespace DSWeb.Common.DB public decimal? GOODSRKSL { get; set; } public decimal? GOODSRKSLACTUAL { get; set; } public decimal? GOODSPFSL { get; set; } + /// + /// 库存量 + /// public decimal? GOODSSTOCK { get; set; } public string CHARGEUNIT { get; set; } public string REMARK_OUT { get; set; } @@ -1878,7 +1881,14 @@ namespace DSWeb.Common.DB public string GOODSSTANDARD { get; set; } public decimal? GOODSPACK { get; set; } public string CHARGEUNIT { get; set; } + + /// + /// 入库量 + /// public decimal? GOODSRKSL { get; set; } + /// + /// 库存量 + /// public decimal? GOODSSTOCK { get; set; } public int? FREESTORAGEPERIOD { get; set; } public bool? ISLOCK { get; set; } @@ -1894,6 +1904,9 @@ namespace DSWeb.Common.DB public string REMARK { get; set; } public decimal? GOODSPACKSTOCK { get; set; } public string KINDPKGS { get; set; } + /// + /// 重量 + /// public decimal? GOODSKGS { get; set; } public string CLIENTCODEOLD { get; set; } public string CLIENTNAMEOLD { get; set; } @@ -1928,6 +1941,9 @@ namespace DSWeb.Common.DB public double CHIMA1 { get; set; } public double CHIMA2 { get; set; } public decimal? ZHONGLIANG2 { get; set; } + /// + /// 实际重量 + /// public double SHIJIZHONGLIANG { get; set; } public double SHIJICHIMA { get; set; } public decimal? JIANSHU1 { get; set; } diff --git a/DSWeb/Areas/CommMng/Controllers/WorkFlowController.cs b/DSWeb/Areas/CommMng/Controllers/WorkFlowController.cs index fffd62e0..81566684 100644 --- a/DSWeb/Areas/CommMng/Controllers/WorkFlowController.cs +++ b/DSWeb/Areas/CommMng/Controllers/WorkFlowController.cs @@ -18,6 +18,8 @@ using DSWeb.Areas.MvcShipping.Job; using System.Runtime.Caching; using DSWeb.Areas.MvcShipping.Models.Message.VGM; using DSWeb.Areas.MvcShipping.Helper; +using HcUtility.Comm; +using DSWeb.MvcShipping.DAL.MsSysParamSet; namespace DSWeb.Areas.CommMng.Controllers { @@ -238,13 +240,20 @@ namespace DSWeb.Areas.CommMng.Controllers //反序列化json串拿去加密字符串 var objRtn = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(strJson.ToString(), new { encrypt = "" }); - - var 钉钉应用 = DingTalkProcess.GetDingTalkProcess("诚锐入货通知"); string ever = objRtn.encrypt; + var appname = MsSysParamSetDAL.GetSysParamValue("DingTalkAppName"); + + //var 钉钉应用 = DingTalkApp.GetDingTalkApp("诚锐东胜对接"); + var 钉钉应用 = DingTalkApp.GetDingTalkApp(appname); + //钉钉应用=DingTalkProcess.GetDingTalkProcessByProcessCode(callbackinfo.processCode); + + //实例化钉钉解密类构造参数为对应的 应用中的token、aes_key、AppKey值 DingTalkEncryptor dingTalkEncryptor = new DingTalkEncryptor(钉钉应用.token, 钉钉应用.aes_key, 钉钉应用.appkey); + + //定义字符串接收解密后的值 string text = dingTalkEncryptor.getDecryptMsg(signature, timestamp, nonce, ever); //JeffSoft.Logger.Error("dingTalkEncryptor.getDecryptMsg:" + text + ""); @@ -252,7 +261,16 @@ namespace DSWeb.Areas.CommMng.Controllers var callbackinfo = JsonConvert.Deserialize(text); - 钉钉应用.SaveCallBack(callbackinfo); + + + var 钉钉审批 = 钉钉应用.GetDingTalkProcessByProcessCode(callbackinfo.processCode); + + + + + + + 钉钉审批.SaveCallBack(callbackinfo); //var objRtn2 = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(text.ToString(), new { EventType = "" }); @@ -271,7 +289,7 @@ namespace DSWeb.Areas.CommMng.Controllers var DDresult = DingCallBackMsg.result; var mes = string.Format("bpms_instance_change Success,title:{0},result:{1}", DDtitle, DDresult); - 钉钉应用.DoDeal(); + 钉钉审批.DoDeal(); //if () //result = DingTalkHelper.DingTalk_Instanceinfo("i0P82FAHT_G9TWJmavxGdg03131673000830"); @@ -302,6 +320,51 @@ namespace DSWeb.Areas.CommMng.Controllers return data; } + [System.Web.Mvc.HttpPost] + public string Test_DingdingCallback(string text) + { + var result = ""; + var _r = new DBResult(); + var 钉钉应用 = DingTalkApp.GetDingTalkApp("诚锐东胜对接"); + + var callbackinfo = JsonConvert.Deserialize(text); + + var 钉钉审批 = 钉钉应用.GetDingTalkProcessByProcessCode(callbackinfo.processCode); + 钉钉审批.SaveCallBack(callbackinfo); + + //var objRtn2 = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(text.ToString(), new { EventType = "" }); + + //var _jsstr = JsonConvert.Serialize(objRtn2); + + //BasicDataRefDAL.SaveLog(_jsstr, "admin", "钉钉回调", "保存2"); + //取出事件类型字段 + //JeffSoft.Logger.Error("DingdingCallback Success,EventType:" + EventType + ""); + //第二部分 + // { //判断事件类型是否是日程事件 + if ("bpms_instance_change" == callbackinfo.EventType) + { + var DingCallBackMsg = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(text.ToString(), new DingCallBackMsg()); + + var DDtitle = DingCallBackMsg.title; + var DDresult = DingCallBackMsg.result; + var mes = string.Format("bpms_instance_change Success,title:{0},result:{1}", DDtitle, DDresult); + + _r= 钉钉审批.DoDeal(); + + //if () + //result = DingTalkHelper.DingTalk_Instanceinfo("i0P82FAHT_G9TWJmavxGdg03131673000830"); + //var _jsstr3 = JsonConvert.Serialize(objRtn2); + //BasicDataRefDAL.SaveLog(_jsstr, "admin", "钉钉回调", "保存3"); + + //JeffSoft.Logger.Error(mes); + } + + + var data = Newtonsoft.Json.JsonConvert.SerializeObject(_r); + + return data; + } + public class CallBackInfo { /// @@ -331,7 +394,7 @@ namespace DSWeb.Areas.CommMng.Controllers /// /// /// - public int createTime { get; set; } + public long? createTime { get; set; } /// /// /// @@ -351,7 +414,7 @@ namespace DSWeb.Areas.CommMng.Controllers /// /// /// - public int taskId { get; set; } + public long? taskId { get; set; } } } } diff --git a/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs b/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs index 0b08c60e..75724379 100644 --- a/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs +++ b/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs @@ -4954,6 +4954,7 @@ namespace DSWeb.Areas.CommMng.DAL var lv = StrToDic(infoList[0].PROPVALUE); if (lv[fieldname] == fieldvalue) { result = lv; + result.Add("BSNO", item.BSNO); return result; } diff --git a/DSWeb/Areas/MvcShipping/DAL/WMSNew/WMSNewDAL.cs b/DSWeb/Areas/MvcShipping/DAL/WMSNew/WMSNewDAL.cs index c200b98c..09c83f66 100644 --- a/DSWeb/Areas/MvcShipping/DAL/WMSNew/WMSNewDAL.cs +++ b/DSWeb/Areas/MvcShipping/DAL/WMSNew/WMSNewDAL.cs @@ -23,6 +23,8 @@ using DSWeb.MvcShipping.Models.MsChFee; using DSWeb.TruckMng.Helper.Repository; using DSWeb.Areas.MvcShipping.Helper; using DSWeb.Common.DB; +using System.Data.Entity.Migrations; +//using DSWeb.MvcShipping.Models.WMS; namespace DSWeb.MvcShipping.DAL.WMSNewDAL { @@ -949,10 +951,11 @@ namespace DSWeb.MvcShipping.DAL.WMSNewDAL { var result = new DBResult(); - //如果是费用入账动作 且配置了钉钉审批入库 则调用 - //result = DingTalkHelper.Send_WMSIN(userid, wmsno); + //如果是费用入账动作 且配置了钉钉审批入库 则调用向钉钉发送新建审批实例方法 + result = DingTalkHelper.Send_WMSIN(userid, wmsno); - result = TestReadDingtalkInstanceinfo(); + //仅用于测试解析读取钉钉审批实例内容 + //result = TestReadDingtalkInstanceinfo(); msg = result.Message; return result.Success; @@ -977,7 +980,7 @@ namespace DSWeb.MvcShipping.DAL.WMSNewDAL } - private static DBResult DoWMSLOCK(string wmsnoListStr) { + public static DBResult DoWMSLOCK(string wmsnoListStr) { var result = new DBResult(); @@ -1025,29 +1028,168 @@ namespace DSWeb.MvcShipping.DAL.WMSNewDAL return result; } + /// + /// 用于测试读取钉钉审批实例内容 + /// + /// public static DBResult TestReadDingtalkInstanceinfo() { var result = new DBResult(); //var userid= + try + { + //如果是费用入账动作 且配置了钉钉审批入库 则调用 + result = DingTalkHelper.DingTalk_Instanceinfo("Wnr2YHcmSD-PjBWkTDkqIg05361673511300"); + + DingTalkInstanceinfo di = JsonConvert.Deserialize(result.Data.ToString()); + + //根据内容修改wms和wmsin值 + var cdc = new CommonDataContext(); + var lv = BasicDataRefDAL.GetLogicHaveValue("钉钉审批", "instanceId", "Wnr2YHcmSD-PjBWkTDkqIg05361673511300"); + if (lv != null && lv.ContainsKey("instanceId")) + { + var wmsno = lv["BSNO"]; + + var wmsold = new Models.WMS.WMS_IN_OLD(wmsno); + var wms = wmsold.wms; + var wmslist = wmsold.wms_in; + //var wms = cdc.wms.FirstOrDefault(x => x.WMSNO == wmsno); + //var wmslist = new List(); + //if (wms != null) { + // wmslist = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList(); + //} + var updwmsinlist = new List(); + var newwmsinlist = new List(); + var 车辆信息 = new wms_in_md(); + foreach (var item in di.result.formComponentValues) + { + //从其中查找货物信息 并更新至当前 + if (item.name == "客户名称") + { + + //var cust=cdc.info_client.Where(x=>x.SHORTNAME==item.value || x.DESCRIPTION==item.value) + } + if (item.name == "入库日期") + { + wms.WMSDATE = Convert.ToDateTime(item.value); + } + if (item.name == "入库信息") + { + var 入库信息list = FormComponentValues.GetRowValues(item.value); + if (入库信息list != null) { + foreach (var DingWmsin in 入库信息list) + { + var 提单号 = DingWmsin.getValue("提单号"); + var 箱号 = DingWmsin.getValue("箱号"); + if (wmslist.Exists(x => x.BLNO == 提单号 && x.CNTRNO == 箱号)) + { + + var updrec = wmslist.First(x => x.BLNO == 提单号 && x.CNTRNO == 箱号); + + //new DingTalkFormField("提单号", item.BLNO), + //new DingTalkFormField("箱号", item.CNTRNO), + //new DingTalkFormField("品名", item.GOODSNAME), + //new DingTalkFormField("重量", item.GOODSRKSL.ToString()), + //new DingTalkFormField("件数", item.GOODSPACK.ToString()), + //new DingTalkFormField("尺码", item.CHIMA1.ToString()), + //new DingTalkFormField("库位", item.CHIMA1.ToString()) + updrec.GOODSNAME = DingWmsin.getValue("品名"); + + if (wms.CHARGEUNIT == "吨"|| wms.CHARGEUNIT == "千克") + { + updrec.GOODSRKSL = Convert.ToDecimal(DingWmsin.getValue("重量")); + updrec.GOODSSTOCK = Convert.ToDecimal(DingWmsin.getValue("重量")); + + updrec.GOODSKGS = Convert.ToDecimal(DingWmsin.getValue("重量")); + updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量")); + + updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码")); + updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码")); + } + + if (wms.CHARGEUNIT == "CBM") + { + updrec.GOODSRKSL = Convert.ToDecimal(DingWmsin.getValue("尺码")); + updrec.GOODSSTOCK = Convert.ToDecimal(DingWmsin.getValue("重量")); + + updrec.GOODSKGS = Convert.ToDecimal(DingWmsin.getValue("重量")); + updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量")); - //如果是费用入账动作 且配置了钉钉审批入库 则调用 - result = DingTalkHelper.DingTalk_Instanceinfo("Wnr2YHcmSD-PjBWkTDkqIg05361673511300"); + updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码")); + updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码")); + } + updrec.GOODSPACK = Convert.ToDecimal(DingWmsin.getValue("件数")); + + updrec.AREANAME = DingWmsin.getValue("库位"); + updrec.DODATE = wms.WMSDATE; + updwmsinlist.Add(updrec); + } + else + { + var newrec = new wms_in_md(); + newrec.ASSOCIATEDNO = wms.GID; + newrec.GID = Guid.NewGuid().ToString(); + newrec.BLNO = DingWmsin.getValue("提单号"); + newrec.CNTRNO = DingWmsin.getValue("箱号"); + newrec.CLIENTNAME = wms.CUSTOMERNAME; + newrec.DODATE = wms.WMSDATE; + newrec.GOODSNAME = DingWmsin.getValue("品名"); + newrec.GOODSRKSL = Convert.ToDecimal(DingWmsin.getValue("重量")); + newrec.GOODSPACK = Convert.ToDecimal(DingWmsin.getValue("件数")); + newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码")); + newrec.AREANAME = DingWmsin.getValue("库位"); + newrec.CREATETIME = DateTime.Now; + newrec.CHARGEUNIT = wms.CHARGEUNIT; + newrec.CORPID = wms.CORPID; + newwmsinlist.Add(newrec); + } + } + } + } - DingTalkInstanceinfo di = JsonConvert.Deserialize(result.Data.ToString()); + if (item.name == "车队信息") + { + var 车队信息list = FormComponentValues.GetRowValues(item.value); + if (车队信息list != null && 车队信息list.Count > 0) + { + var 车队name = 车队信息list[0].getValue("车队"); + var 车队 = cdc.info_client.FirstOrDefault(x => x.SHORTNAME == 车队name); + if (车队 != null && 车队.SHORTNAME != null && 车队.SHORTNAME != "") + { + 车辆信息.CHEDUIID = 车队.GID; + 车辆信息.TRUCKNO = 车队信息list[0].getValue("车牌号"); + } + } - //根据内容修改wms和wmsin值 - var cdc = new CommonDataContext(); - var lv= BasicDataRefDAL.GetLogicHaveValue("钉钉审批", "instanceId", "Wnr2YHcmSD-PjBWkTDkqIg05361673511300"); - if (lv != null && lv.ContainsKey("instanceId")) { - var wmsno = lv["BSNO"]; - var wms = cdc.wms.FirstOrDefault(x => x.WMSNO == wmsno); - var wmslist = new List(); - if (wms != null) { - wmslist = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList(); + } + } + cdc.wms.AddOrUpdate(wms); + if (updwmsinlist != null && updwmsinlist.Count > 0) + { + foreach (var item in updwmsinlist) + { + item.CHEDUIID = 车辆信息.CHEDUIID; + item.TRUCKNO = 车辆信息.TRUCKNO; + cdc.wms_in.AddOrUpdate(item); + } + } + if (newwmsinlist != null && newwmsinlist.Count > 0) + { + foreach (var item in newwmsinlist) + { + item.CHEDUIID = 车辆信息.CHEDUIID; + item.TRUCKNO = 车辆信息.TRUCKNO; + cdc.wms_in.AddOrUpdate(item); + } + } + cdc.SaveChanges(); } } + catch (Exception e) { + result.SetErrorInfo(e.Message); + } return result; } diff --git a/DSWeb/Areas/MvcShipping/Helper/DingTalkHelper.cs b/DSWeb/Areas/MvcShipping/Helper/DingTalkHelper.cs index 6b7ea32d..d7659227 100644 --- a/DSWeb/Areas/MvcShipping/Helper/DingTalkHelper.cs +++ b/DSWeb/Areas/MvcShipping/Helper/DingTalkHelper.cs @@ -12,6 +12,7 @@ using java.util; using log4net; using Microsoft.Office.Interop.Excel; using Newtonsoft.Json; +using NPOI.OpenXmlFormats.Wordprocessing; using System; using System.Collections.Generic; using System.Configuration; @@ -25,6 +26,10 @@ using System.Web; using Tea; using static DSWeb.Areas.CommMng.Controllers.WorkFlowController; using static DSWeb.Areas.MvcShipping.Helper.DingTalk_SendAuditWork; +using Newtonsoft.Json.Linq; +using sun.tools.jar.resources; +using System.Data.Entity.Migrations; +using AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models; namespace DSWeb.Areas.MvcShipping.Helper { @@ -145,6 +150,15 @@ namespace DSWeb.Areas.MvcShipping.Helper } result = dh.DoSend(); + + if (result.Success) { + //将wms锁定状态改为是 + var cdc = new CommonDataContext(); + var _wmsno= wmsno.Replace("'", ""); + var wms = cdc.wms.First(x => x.WMSNO == _wmsno); + wms.ISLOCK2= true; + cdc.SaveChanges(); + } } else { result.SetErrorInfo("该业务已发送"); @@ -372,7 +386,9 @@ namespace DSWeb.Areas.MvcShipping.Helper DingTalk_OAAuditBody body = new DingTalk_OAAuditBody(); - var dp = DingTalkProcess.GetDingTalkProcess("诚锐入货通知"); + var 诚锐app = DingTalkApp.GetDingTalkApp("诚锐东胜对接"); + + var dp = 诚锐app.GetProcess("诚锐入货通知"); body.deptId = dp.deptid;// //获取用户的钉钉id @@ -406,7 +422,7 @@ namespace DSWeb.Areas.MvcShipping.Helper new DingTalkFormField("重量", item.GOODSRKSL.ToString()), new DingTalkFormField("件数", item.GOODSPACK.ToString()), new DingTalkFormField("尺码", item.CHIMA1.ToString()), - new DingTalkFormField("库位", item.CHIMA1.ToString()) + new DingTalkFormField("库位", item.AREANAME.ToString()) }; 入库信息list.Add(newrk); @@ -555,8 +571,199 @@ namespace DSWeb.Areas.MvcShipping.Helper type = callbackinfo.type; } - } + public DBResult ReadDingtalkInstanceinfo() + { + + var result = new DBResult(); + + //var userid= + try + { + //如果是费用入账动作 且配置了钉钉审批入库 则调用 + result = DingTalkHelper.DingTalk_Instanceinfo(processInstanceId); + + DingTalkInstanceinfo di = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize(result.Data.ToString()); + //根据内容修改wms和wmsin值 + var cdc = new CommonDataContext(); + var lv = BasicDataRefDAL.GetLogicHaveValue("钉钉审批", "instanceId", "Wnr2YHcmSD-PjBWkTDkqIg05361673511300"); + if (lv != null && lv.ContainsKey("instanceId")) + { + var wmsno = lv["BSNO"]; + + var wmsold = new DSWeb.MvcShipping.Models.WMS.WMS_IN_OLD(wmsno); + var wms = wmsold.wms; + var wmslist = wmsold.wms_in; + //var wms = cdc.wms.FirstOrDefault(x => x.WMSNO == wmsno); + //var wmslist = new List(); + //if (wms != null) { + // wmslist = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList(); + //} + var updwmsinlist = new List(); + var newwmsinlist = new List(); + var 车辆信息 = new wms_in_md(); + foreach (var item in di.result.formComponentValues) + { + //从其中查找货物信息 并更新至当前 + if (item.name == "客户名称") + { + + //var cust=cdc.info_client.Where(x=>x.SHORTNAME==item.value || x.DESCRIPTION==item.value) + } + if (item.name == "入库日期") + { + wms.WMSDATE = Convert.ToDateTime(item.value); + } + if (item.name == "入库信息") + { + var 入库信息list = FormComponentValues.GetRowValues(item.value); + if (入库信息list != null) + { + foreach (var DingWmsin in 入库信息list) + { + var 提单号 = DingWmsin.getValue("提单号"); + var 箱号 = DingWmsin.getValue("箱号"); + if (wmslist.Exists(x => x.BLNO == 提单号 && x.CNTRNO == 箱号)) + { + + var updrec = wmslist.First(x => x.BLNO == 提单号 && x.CNTRNO == 箱号); + + //new DingTalkFormField("提单号", item.BLNO), + //new DingTalkFormField("箱号", item.CNTRNO), + //new DingTalkFormField("品名", item.GOODSNAME), + //new DingTalkFormField("重量", item.GOODSRKSL.ToString()), + //new DingTalkFormField("件数", item.GOODSPACK.ToString()), + //new DingTalkFormField("尺码", item.CHIMA1.ToString()), + //new DingTalkFormField("库位", item.CHIMA1.ToString()) + updrec.GOODSNAME = DingWmsin.getValue("品名"); + + if (wms.CHARGEUNIT == "吨" || wms.CHARGEUNIT == "千克") + { + updrec.GOODSRKSL = Convert.ToDecimal(DingWmsin.getValue("重量")); + updrec.GOODSSTOCK = Convert.ToDecimal(DingWmsin.getValue("重量")); + + updrec.GOODSKGS = Convert.ToDecimal(DingWmsin.getValue("重量")); + updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量")); + + updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码")); + updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码")); + } + + if (wms.CHARGEUNIT == "CBM") + { + updrec.GOODSRKSL = Convert.ToDecimal(DingWmsin.getValue("尺码")); + updrec.GOODSSTOCK = Convert.ToDecimal(DingWmsin.getValue("重量")); + + updrec.GOODSKGS = Convert.ToDecimal(DingWmsin.getValue("重量")); + updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量")); + + updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码")); + updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码")); + } + updrec.GOODSPACK = Convert.ToDecimal(DingWmsin.getValue("件数")); + + updrec.AREANAME = DingWmsin.getValue("库位"); + updrec.DODATE = wms.WMSDATE; + updwmsinlist.Add(updrec); + } + else + { + var newrec = new wms_in_md(); + newrec.ASSOCIATEDNO = wms.GID; + newrec.GID = Guid.NewGuid().ToString(); + newrec.BLNO = DingWmsin.getValue("提单号"); + newrec.CNTRNO = DingWmsin.getValue("箱号"); + newrec.CLIENTNAME = wms.CUSTOMERNAME; + newrec.DODATE = wms.WMSDATE; + newrec.GOODSNAME = DingWmsin.getValue("品名"); + + if (wms.CHARGEUNIT == "吨" || wms.CHARGEUNIT == "千克") + { + newrec.GOODSRKSL = Convert.ToDecimal(DingWmsin.getValue("重量")); + newrec.GOODSSTOCK = Convert.ToDecimal(DingWmsin.getValue("重量")); + + newrec.GOODSKGS = Convert.ToDecimal(DingWmsin.getValue("重量")); + newrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量")); + + newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码")); + newrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码")); + } + + if (wms.CHARGEUNIT == "CBM") + { + newrec.GOODSRKSL = Convert.ToDecimal(DingWmsin.getValue("尺码")); + newrec.GOODSSTOCK = Convert.ToDecimal(DingWmsin.getValue("重量")); + + newrec.GOODSKGS = Convert.ToDecimal(DingWmsin.getValue("重量")); + newrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量")); + + newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码")); + newrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码")); + } + newrec.GOODSPACK = Convert.ToDecimal(DingWmsin.getValue("件数")); + newrec.AREANAME = DingWmsin.getValue("库位"); + newrec.CREATETIME = DateTime.Now; + newrec.CHARGEUNIT = wms.CHARGEUNIT; + newrec.CORPID = wms.CORPID; + newwmsinlist.Add(newrec); + } + } + } + } + + if (item.name == "车队信息") + { + var 车队信息list = FormComponentValues.GetRowValues(item.value); + if (车队信息list != null && 车队信息list.Count > 0) + { + var 车队name = 车队信息list[0].getValue("车队"); + var 车队 = cdc.info_client.FirstOrDefault(x => x.SHORTNAME == 车队name); + if (车队 != null && 车队.SHORTNAME != null && 车队.SHORTNAME != "") + { + 车辆信息.CHEDUIID = 车队.GID; + 车辆信息.TRUCKNO = 车队信息list[0].getValue("车牌号"); + } + } + + } + } + cdc.wms.AddOrUpdate(wms); + if (updwmsinlist != null && updwmsinlist.Count > 0) + { + foreach (var item in updwmsinlist) + { + item.CHEDUIID = 车辆信息.CHEDUIID; + item.TRUCKNO = 车辆信息.TRUCKNO; + cdc.wms_in.AddOrUpdate(item); + } + } + if (newwmsinlist != null && newwmsinlist.Count > 0) + { + foreach (var item in newwmsinlist) + { + item.CHEDUIID = 车辆信息.CHEDUIID; + item.TRUCKNO = 车辆信息.TRUCKNO; + cdc.wms_in.AddOrUpdate(item); + } + } + + wms.ISLOCK2 = false; + cdc.wms.AddOrUpdate(wms); + + cdc.SaveChanges(); + + //然后执行入库的费用入账原逻辑 + DSWeb.MvcShipping.DAL.WMSNewDAL.WMSNewDAL.DoWMSLOCK(wmsno); + } + } + catch (Exception e) + { + result.SetErrorInfo(e.Message); + } + + return result; + } + } public class OperationRecords { @@ -601,20 +808,25 @@ namespace DSWeb.Areas.MvcShipping.Helper /// public string value { get; set; } - public 行信息 GetRowValues() { - - + public static List GetRowValues(string value) + { //用value值文本来解析成 行信息 - var result = new 行信息(); + var result = new List(); - if (value.Contains("\\\"rowValue\\\"")) + if (value.Contains("\"rowValue\"")) { try { - var _value = value.Replace("\\", ""); - var hxx = JsonConvert.DeserializeObject<行信息>(_value); - result = hxx; + var jarr = JArray.Parse(value); + foreach (var item in jarr) + { + var obj = item as JObject; + + var row =JsonConvert.DeserializeObject(obj.ToString()); + result.Add(row); + } + } catch (Exception ex) { } @@ -636,6 +848,10 @@ namespace DSWeb.Areas.MvcShipping.Helper /// /// /// + public string finishTime { get; set; } + /// + /// + /// public string pcUrl { get; set; } /// /// @@ -652,7 +868,7 @@ namespace DSWeb.Areas.MvcShipping.Helper /// /// /// - public int taskId { get; set; } + public long? taskId { get; set; } /// /// /// @@ -661,6 +877,10 @@ namespace DSWeb.Areas.MvcShipping.Helper public class Result { + /// + /// + /// + public string finishTime { get; set; } /// /// /// @@ -728,13 +948,19 @@ namespace DSWeb.Areas.MvcShipping.Helper } public class 行信息 + { + public List row { get; set; } + + } + public class row { public List rowValue { get; set; } public string rowNumber { get; set; } - - public string getValue(string fieldname) { + public string getValue(string fieldname) + { var result = ""; - if (rowValue.Exists(x => x.label == fieldname)) { + if (rowValue.Exists(x => x.label == fieldname)) + { result = rowValue.First(x => x.label == fieldname).value; } return result; @@ -747,42 +973,99 @@ namespace DSWeb.Areas.MvcShipping.Helper public string value { get; set; } public string key { get; set; } } + + #endregion #region 钉钉业务类 - public class DingTalkProcess { - - public string processname { get; set; } - public string processCode { get; set; } + public class DingTalkApp { public string token { get; set; } public string aes_key { get; set; } public string appkey { get; set; } public long agentid { get; set; } public long deptid { get; set; } - //public string callbackstr { get; set; } + public static DingTalkApp GetDingTalkApp(string appname) + { - public DingTalkCallbackDealHelper callbackinfo { get; set; } + var result = new DingTalkApp(); + if (appname == "ddlucky测试应用") + { + result = new DingTalkApp_ddlucky测试应用(); + return result; - public void SaveCallBack(CallBackInfo _callbackinfo) { - callbackinfo = new DingTalkCallbackDealHelper(_callbackinfo); + } + if (appname == "诚锐东胜对接") + { + result = new DingTalkApp_诚锐东胜对接(); + return result; + } + return result; } - public DingTalkProcess() { } - public DingTalkProcess(string processname) { this.processname = processname; } - /// - /// 这些数值来自于钉钉中某个组织的某个应用。一个应用可以监听多个实际业务的返回值 - /// - /// - /// - public static DingTalkProcess GetDingTalkProcess(string processname) { + public virtual DingTalkProcess GetProcess(string processname) { + return new DingTalkProcess(); + } + + public virtual DingTalkProcess GetDingTalkProcessByProcessCode(string processcode) + { + return new DingTalkProcess(); + } + } + + + public class DingTalkApp_ddlucky测试应用 : DingTalkApp + { + public DingTalkApp_ddlucky测试应用() { + token = "zbGFOwrH6zCvq3VE3izLmWRTNUC1YcX"; + aes_key = "sb6GkCKsUwNQo3RKbX1MzHKea1ZsE221n3xQ9hwJBMK"; + appkey = "dingsaofiohmsrcbxyef"; + agentid = 2298782307; + deptid = 809181118; + } + + public static DingTalkProcess GetDingTalkProcess(string processname) + { var result = new DingTalkProcess(); - if (processname == "测试入货通知") { + if (processname == "测试入货通知") + { result = new DingTalkProcess_测试入货通知(processname); return result; - + + } + return result; + } + + public static DingTalkProcess GetDingTalkProcessByProcessCode(string processCode) + { + var processdic = new Dictionary { + { "PROC-0DC40EA2-E9D2-4917-A597-AD77EC055C49","测试入货通知"} + }; + + if (processdic.ContainsKey(processCode)) + { + return GetDingTalkProcess(processdic[processCode]); } + else { return new DingTalkProcess(); } + } + } + + public class DingTalkApp_诚锐东胜对接 : DingTalkApp + { + public DingTalkApp_诚锐东胜对接() + { + token = "CWhvNvfyuNf9D8halMs5PyHV70CrFx3E"; + aes_key = "O5u6L8YnUaucnC8FyFNMeMeGE5uoYSAGFGdg3rOHftt"; + appkey = "dingkt5caipnn4fbuqsf"; + agentid = 2365401074; + deptid = 432400353; + } + + public static DingTalkProcess GetDingTalkProcess(string processname) + { + + var result = new DingTalkProcess(); if (processname == "诚锐入货通知") { result = new DingTalkProcess_诚锐入库(processname); @@ -791,6 +1074,45 @@ namespace DSWeb.Areas.MvcShipping.Helper return result; } + new public static DingTalkProcess GetDingTalkProcessByProcessCode(string processCode) + { + var processdic = new Dictionary { + { "PROC-0888A19C-0562-42AC-A9C6-24E4C4398410","诚锐入货通知"} + }; + + if (processdic.ContainsKey(processCode)) + { + return GetDingTalkProcess(processdic[processCode]); + } + else { return new DingTalkProcess(); } + } + } + + public class DingTalkProcess: DingTalkApp + { + + public string processname { get; set; } + public string processCode { get; set; } + + + //public string callbackstr { get; set; } + + public DingTalkCallbackDealHelper callbackinfo { get; set; } + + public void SaveCallBack(CallBackInfo _callbackinfo) { + callbackinfo = new DingTalkCallbackDealHelper(_callbackinfo); + } + + + public DingTalkProcess() { } + public DingTalkProcess(string processname) { this.processname = processname; } + /// + /// 这些数值来自于钉钉中某个组织的某个应用。一个应用可以监听多个实际业务的返回值 + /// + /// + /// + + public virtual DBResult DoDeal() { return new DBResult(); } } @@ -799,12 +1121,14 @@ namespace DSWeb.Areas.MvcShipping.Helper public DingTalkProcess_测试入货通知(string processname) { this.processname = processname; + + //token = "zbGFOwrH6zCvq3VE3izLmWRTNUC1YcX"; + //aes_key = "sb6GkCKsUwNQo3RKbX1MzHKea1ZsE221n3xQ9hwJBMK"; + //appkey = "dingsaofiohmsrcbxyef"; + //agentid = 2298782307; + processCode = "PROC-0DC40EA2-E9D2-4917-A597-AD77EC055C49"; - token = "zbGFOwrH6zCvq3VE3izLmWRTNUC1YcX"; - aes_key = "sb6GkCKsUwNQo3RKbX1MzHKea1ZsE221n3xQ9hwJBMK"; - appkey = "dingsaofiohmsrcbxyef"; - agentid = 2298782307; - agentid = 809181118; + } @@ -823,17 +1147,20 @@ namespace DSWeb.Areas.MvcShipping.Helper { public DingTalkProcess_诚锐入库(string processname) { this.processname = processname; + + //token = "CWhvNvfyuNf9D8halMs5PyHV70CrFx3E"; + //aes_key = "O5u6L8YnUaucnC8FyFNMeMeGE5uoYSAGFGdg3rOHftt"; + //appkey = "dingkt5caipnn4fbuqsf"; + //agentid = 2365401074; + processCode = "PROC-0888A19C-0562-42AC-A9C6-24E4C4398410"; - token = "CWhvNvfyuNf9D8halMs5PyHV70CrFx3E"; - aes_key = "O5u6L8YnUaucnC8FyFNMeMeGE5uoYSAGFGdg3rOHftt"; - appkey = "dingkt5caipnn4fbuqsf"; - agentid = 2365401074; - deptid = 432400353; + } public override DBResult DoDeal() { - return new DBResult(); + //return new DBResult(); + return callbackinfo.ReadDingtalkInstanceinfo(); } } diff --git a/DSWeb/Areas/MvcShipping/Models/WMS/WMS.cs b/DSWeb/Areas/MvcShipping/Models/WMS/WMS.cs index 830ddca0..6bd997a6 100644 --- a/DSWeb/Areas/MvcShipping/Models/WMS/WMS.cs +++ b/DSWeb/Areas/MvcShipping/Models/WMS/WMS.cs @@ -3,6 +3,8 @@ using DSWeb.Common.DB; using System.Collections.Generic; using HcUtility.Core; using Newtonsoft.Json; +using DSWeb.Areas.CommMng.DAL; +using System.Linq; namespace DSWeb.MvcShipping.Models.WMS { @@ -2995,7 +2997,16 @@ namespace DSWeb.MvcShipping.Models.WMS public WMS_IN_OLD() { } - public WMS_IN_OLD(string wmsno) { + public WMS_IN_OLD(string wmsno) { + + var cdc = new CommonDataContext(); + + wms = cdc.wms.FirstOrDefault(x => x.WMSNO == wmsno); + + if (wms != null) + { + wms_in = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList(); + } } }