|
|
|
|
using AlibabaCloud.SDK.Dingtalkh5package_1_0.Models;
|
|
|
|
|
using AlibabaCloud.SDK.Dingtalkvillage_1_0.Models;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using DSWeb.Areas.Dispatch.Helper;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.DB;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.Job;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.Models.MsOpSeaeBaoXian;
|
|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using java.rmi.server;
|
|
|
|
|
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;
|
|
|
|
|
using System.Diagnostics.Contracts;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.Caching;
|
|
|
|
|
using System.Runtime.Serialization.Json;
|
|
|
|
|
using System.Text;
|
|
|
|
|
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;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using DSWeb.MvcShipping.Models.DingTalkSet;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.MvcShipping.Helper
|
|
|
|
|
{
|
|
|
|
|
public static class DingTalkHelper
|
|
|
|
|
{
|
|
|
|
|
public static readonly string DingTalkAccessTokenStoreKey = "DingTalkToken";
|
|
|
|
|
|
|
|
|
|
private static ILog logger = LogManager.GetLogger("DingTalkHelper");
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发送工作通知
|
|
|
|
|
/// https://open-dev.dingtalk.com/apiExplorer#/?devType=org&api=dingtalk.oapi.message.corpconversation.asyncsend_v2
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="uid"></param>
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
|
|
public static bool SendMessage(string uid, string msg)
|
|
|
|
|
{
|
|
|
|
|
DingTalkContext dingTalkContext = new DingTalkContext();
|
|
|
|
|
|
|
|
|
|
var pAgentid = dingTalkContext.ParamSets.FirstOrDefault(p => p.PARAMNAME == "DingTalkAgentid");
|
|
|
|
|
if (pAgentid == null || string.IsNullOrWhiteSpace(pAgentid.PARAMVALUE))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("钉钉Agentid参数配置错误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var user = dingTalkContext.Users.FirstOrDefault(u => u.GID == uid);
|
|
|
|
|
if (user != null && !string.IsNullOrWhiteSpace(user.DingTalkAccount))
|
|
|
|
|
{
|
|
|
|
|
var token = MemoryCache.Default[DingTalkTokenJob.DingTalkAccessTokenStoreKey].ToString();
|
|
|
|
|
var json = new
|
|
|
|
|
{
|
|
|
|
|
agent_id = pAgentid.PARAMVALUE,
|
|
|
|
|
userid_list = user.DingTalkAccount,
|
|
|
|
|
msg = new
|
|
|
|
|
{
|
|
|
|
|
msgtype = "text",
|
|
|
|
|
text = new
|
|
|
|
|
{
|
|
|
|
|
content = msg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string resp = WebRequestHelper.DoPost($"https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token={token}", JsonConvert.SerializeObject(json));
|
|
|
|
|
logger.Debug(resp);
|
|
|
|
|
var jsonObj = JsonConvert.DeserializeAnonymousType(resp, new
|
|
|
|
|
{
|
|
|
|
|
errcode = 0,
|
|
|
|
|
errmsg = "",
|
|
|
|
|
task_id = ""
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (jsonObj.errcode == 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取实例当前值 data内容是json文本
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="instanceId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static DBResult DingTalk_Instanceinfo(string instanceId) {
|
|
|
|
|
//https://open.dingtalk.com/document/isvapp-server/queries-a-process-instance-based-on-its-id
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
DingTalk_Instanceinfo dh = new DingTalk_Instanceinfo();
|
|
|
|
|
|
|
|
|
|
dh.MakeSendMessage(instanceId);//i0P82FAHT_G9TWJmavxGdg03131673000830
|
|
|
|
|
|
|
|
|
|
result = dh.DoSend();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public static DBResult DingTalk_ReadWMSINInstance(string instanceId)
|
|
|
|
|
//{
|
|
|
|
|
// var result = new DBResult();
|
|
|
|
|
// var instanceiddic = BasicDataRefDAL.GetLogicInfo(wmsno, "钉钉审批");
|
|
|
|
|
|
|
|
|
|
// if (instanceiddic == null || !instanceiddic.ContainsKey("instanceId"))
|
|
|
|
|
// {
|
|
|
|
|
// return result.SetErrorInfo(wmsno + "没有进行钉钉审批");
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// var _r = DingTalk_Instanceinfo(instanceId);
|
|
|
|
|
// if (!_r.Success)
|
|
|
|
|
// {
|
|
|
|
|
// return _r;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 如果成功 用数据对象解析结果 并做相应处理
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult Send_WMSIN(string uid, string wmsno)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
DingTalk_WmsInAudit dh = new DingTalk_WmsInAudit(uid);
|
|
|
|
|
|
|
|
|
|
var cansend = dh.cansend_in(wmsno);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cansend.Success)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result= dh.MakeSendMessage(wmsno);
|
|
|
|
|
if (!result.Success) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public static DBResult Send_WMSOUT(string uid, string BSNO)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
DingTalk_WmsOutAudit dh = new DingTalk_WmsOutAudit(uid);
|
|
|
|
|
|
|
|
|
|
if (dh.cansend_out(BSNO))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result = dh.MakeSendMessage(BSNO);
|
|
|
|
|
if (!result.Success)
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = dh.DoSend();
|
|
|
|
|
|
|
|
|
|
if (result.Success)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo("该业务已发送");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class DingTalkSendHelper {
|
|
|
|
|
|
|
|
|
|
public DingTalkSendHelper() { }
|
|
|
|
|
|
|
|
|
|
public string url { get; set; }
|
|
|
|
|
public string uid { get; set; }
|
|
|
|
|
public object SendObject { get; set; }
|
|
|
|
|
public SysParamSet pAgentid { get; set; }
|
|
|
|
|
|
|
|
|
|
public DB.User user { get; set; } = null;
|
|
|
|
|
public object jsonObj { get; set; }
|
|
|
|
|
public Dictionary<string, string> dicObj { get; set; } = new Dictionary<string, string>();
|
|
|
|
|
public string json { get; set; }
|
|
|
|
|
public string token { get; set; }
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, string> HeaderDic { get; set; }
|
|
|
|
|
|
|
|
|
|
private static ILog logger = LogManager.GetLogger("DingTalkHelper");
|
|
|
|
|
|
|
|
|
|
public DingTalkContext dingTalkContext { get; set; } = new DingTalkContext();
|
|
|
|
|
DBResult result { get; set; } = new DBResult();
|
|
|
|
|
|
|
|
|
|
public DBResult getUser()
|
|
|
|
|
{
|
|
|
|
|
user = dingTalkContext.Users.FirstOrDefault(u => u.GID == uid);
|
|
|
|
|
if (user == null || string.IsNullOrWhiteSpace(user.DingTalkAccount))
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo("用户没有维护钉钉userid");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
result.OK();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult GetAgentid() {
|
|
|
|
|
result = new DBResult();
|
|
|
|
|
pAgentid = dingTalkContext.ParamSets.FirstOrDefault(p => p.PARAMNAME == "DingTalkAgentid");
|
|
|
|
|
if (pAgentid == null || string.IsNullOrWhiteSpace(pAgentid.PARAMVALUE))
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo("钉钉Agentid参数配置错误");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
result.OK();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult DoSend() {
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
string resp = WebRequestHelper.DoPost(url, JsonConvert.SerializeObject(jsonObj));
|
|
|
|
|
|
|
|
|
|
logger.Debug(resp);
|
|
|
|
|
|
|
|
|
|
result.setMessage(true,"发送成功", jsonObj);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult DoSend_Header()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
string resp = "";
|
|
|
|
|
|
|
|
|
|
if (jsonObj != null)
|
|
|
|
|
{
|
|
|
|
|
BasicDataRefDAL.SaveLog("url:" + url+ "header:" +JsonConvert.SerializeObject(HeaderDic)+" body:"+ JsonConvert.SerializeObject(jsonObj),"","钉钉审核","发出");
|
|
|
|
|
resp=WebRequestHelper.DoPost_Header(url, HeaderDic, jsonObj);
|
|
|
|
|
BasicDataRefDAL.SaveLog(resp, "", "钉钉审核", "返回");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
resp=WebRequestHelper.DoPost_Header(url, HeaderDic);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.Debug(resp);
|
|
|
|
|
|
|
|
|
|
result.setMessage(true, "发送成功", resp);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult DoGet_Header_Param()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
string resp = WebRequestHelper.DoGet_Header_Param(url, HeaderDic, dicObj);
|
|
|
|
|
|
|
|
|
|
//logger.Debug(resp);
|
|
|
|
|
|
|
|
|
|
result.setMessage(true, "发送成功", resp);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static object JsonToObject(string jsonString, object obj)
|
|
|
|
|
{
|
|
|
|
|
DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
|
|
|
|
|
MemoryStream mStream = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
|
|
|
|
|
return serializer.ReadObject(mStream);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalk_SendWorkMessage : DingTalkSendHelper {
|
|
|
|
|
public DingTalk_SendWorkMessage(string uid) {
|
|
|
|
|
|
|
|
|
|
this.uid = uid;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult MakeSendMessage(string msg) {
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
result = GetAgentid();
|
|
|
|
|
if (!result.Success) return result;
|
|
|
|
|
|
|
|
|
|
result = getUser();
|
|
|
|
|
if (!result.Success) return result;
|
|
|
|
|
|
|
|
|
|
jsonObj = new
|
|
|
|
|
{
|
|
|
|
|
agent_id = pAgentid.PARAMVALUE,
|
|
|
|
|
userid_list = user.DingTalkAccount,
|
|
|
|
|
msg = new
|
|
|
|
|
{
|
|
|
|
|
msgtype = "text",
|
|
|
|
|
text = new
|
|
|
|
|
{
|
|
|
|
|
content = msg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
token = MemoryCache.Default[DingTalkTokenJob.DingTalkAccessTokenStoreKey].ToString();
|
|
|
|
|
|
|
|
|
|
url = $"https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token={token}";
|
|
|
|
|
result.OK();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalk_SendAuditWork : DingTalkSendHelper
|
|
|
|
|
{
|
|
|
|
|
public string BSNO { get; set; }
|
|
|
|
|
public DingTalk_SendAuditWork()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public DingTalk_SendAuditWork(string uid)
|
|
|
|
|
{
|
|
|
|
|
this.uid = uid;
|
|
|
|
|
getUser();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalkFormField {
|
|
|
|
|
public string name { get; set; }
|
|
|
|
|
public string value { get; set; }
|
|
|
|
|
public DingTalkFormField(string name, string value)
|
|
|
|
|
{
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalkForm_approvers
|
|
|
|
|
{
|
|
|
|
|
public string actionType { get; set; }
|
|
|
|
|
public List<string> userIds { get; set; }
|
|
|
|
|
|
|
|
|
|
public DingTalkForm_approvers(string actionType, List<string> userIds)
|
|
|
|
|
{
|
|
|
|
|
this.actionType = actionType;
|
|
|
|
|
this.userIds = userIds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalk_OAAuditBody {
|
|
|
|
|
|
|
|
|
|
public long deptId { get; set; }
|
|
|
|
|
public List<DingTalkForm_approvers> approvers { get; set; } = new List<DingTalkForm_approvers>();
|
|
|
|
|
public long microappAgentId { get; set; }
|
|
|
|
|
public string originatorUserId { get; set; }
|
|
|
|
|
public string processCode { get; set; }
|
|
|
|
|
public List<DingTalkFormField> formComponentValues { get; set; } = new List<DingTalkFormField>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public DBResult cansend_in(string wmsno)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
result.OK();
|
|
|
|
|
//var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
//var head = cdc.wms.First(x => x.WMSNO == wmsno);
|
|
|
|
|
//var body = cdc.wms_in.Where(x => x.ASSOCIATEDNO == head.GID).ToList();
|
|
|
|
|
|
|
|
|
|
//foreach (var item in body) {
|
|
|
|
|
// var mblnobody_other = cdc.wms_in.Where(x => x.BLNO == item.BLNO && x.GID != item.GID).ToList();
|
|
|
|
|
|
|
|
|
|
// if (mblnobody_other == null || mblnobody_other.Count == 0)
|
|
|
|
|
// {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// if (mblnobody_other.Exists(x => x.CNTRNO == item.CNTRNO && x.GOODSNAME == item.GOODSNAME)) {
|
|
|
|
|
// var errorHead_gid = mblnobody_other.First(x => x.CNTRNO == item.CNTRNO && x.GOODSNAME == item.GOODSNAME).ASSOCIATEDNO;
|
|
|
|
|
// var errorHead = cdc.wms.First(x => x.GID == errorHead_gid);
|
|
|
|
|
// result.SetErrorInfo("已存在提单号相同、箱号相同的其他入库明细信息,该种入库数据在出库时无法正确区分识别。如实际没有箱号,则请在箱号中输入一个不重复的顺序号。");
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool cansend_out(string BSNO) {
|
|
|
|
|
|
|
|
|
|
//看是否已发过
|
|
|
|
|
//var logiclog = BasicDataRefDAL.GetLogicInfo(GID, "钉钉审批");
|
|
|
|
|
|
|
|
|
|
//if (logiclog.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// return false;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//20230129 判断该业务的明细是否存在【 提单号 箱号 品名三列完全一致的】 如果存在 则返回错误
|
|
|
|
|
//var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
//var detail = cdc.wms_out_detail.Where(x => x.OUTBSNO == BSNO).ToList();
|
|
|
|
|
|
|
|
|
|
//foreach (var item in detail) {
|
|
|
|
|
// if(detail.Exists(x=>x.GID!=item.GID && x.CntrNo))
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//20230129 改为任何时候都可以发 但是重发的话会覆盖op_logicinfo.propvalue中已存在的instanceid
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual DBResult MakeSendMessage(string wmsno)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalk_SendAuditResult {
|
|
|
|
|
public string instanceId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult DoSend() {
|
|
|
|
|
var result = base.DoSend_Header();
|
|
|
|
|
|
|
|
|
|
if (result.Success) {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var jo = new DingTalk_SendAuditResult();
|
|
|
|
|
|
|
|
|
|
jo = (DingTalk_SendAuditResult)JsonToObject(result.Data.ToString(), jo);
|
|
|
|
|
|
|
|
|
|
var dic = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "instanceId", jo.instanceId }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BasicDataRefDAL.SaveLogicInfo(BSNO, "钉钉审批", dic);
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalk_WmsInAudit : DingTalk_SendAuditWork
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public DingTalk_WmsInAudit(string uid)
|
|
|
|
|
{
|
|
|
|
|
this.uid = uid;
|
|
|
|
|
getUser();
|
|
|
|
|
}
|
|
|
|
|
//public bool cansend(string GID)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// //看是否已发过
|
|
|
|
|
// var logiclog = BasicDataRefDAL.GetLogicInfo(GID, "钉钉审批");
|
|
|
|
|
|
|
|
|
|
// if (logiclog.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// return true;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
public override DBResult MakeSendMessage(string wmsno)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
wmsno = wmsno.Replace("'", "");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(user.DingTalkAccount))
|
|
|
|
|
{
|
|
|
|
|
return result.SetErrorInfo("请配置用户的钉钉id");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BSNO = wmsno;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DingTalk_OAAuditBody body = new DingTalk_OAAuditBody();
|
|
|
|
|
|
|
|
|
|
var 诚锐app = DingTalkApp.GetDingTalkApp("诚锐东胜对接");
|
|
|
|
|
|
|
|
|
|
var dp = 诚锐app.GetProcess("诚锐入货通知");
|
|
|
|
|
|
|
|
|
|
body.deptId = dp.deptid;//
|
|
|
|
|
//获取用户的钉钉id
|
|
|
|
|
var dtc = new DingTalkContext();
|
|
|
|
|
|
|
|
|
|
//20230116 改为不指定审核人 完全依照审核流程自身的安排
|
|
|
|
|
//body.approvers.Add(new DingTalkForm_approvers("OR", new List<string> { "5620105362687730" }));
|
|
|
|
|
body.microappAgentId = dp.agentid;//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
body.originatorUserId = user.DingTalkAccount;
|
|
|
|
|
body.processCode = dp.processCode;
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var wms = cdc.wms.First(p => p.WMSNO == wmsno);
|
|
|
|
|
var wmsinList = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList();
|
|
|
|
|
|
|
|
|
|
var 入库信息list = new List<List<DingTalkFormField>>();
|
|
|
|
|
var 车队信息list = new List<List<DingTalkFormField>>();
|
|
|
|
|
|
|
|
|
|
var 车队idlist = wmsinList.Select(s => s.CHEDUIID).ToList();
|
|
|
|
|
var 车队list = cdc.info_client.Where(x => 车队idlist.Contains(x.GID)).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var item in wmsinList)
|
|
|
|
|
{
|
|
|
|
|
var 车队 = "无";
|
|
|
|
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(item.CHEDUIID))
|
|
|
|
|
车队 = 车队list.First(x => x.GID == item.CHEDUIID).SHORTNAME;
|
|
|
|
|
|
|
|
|
|
var 车牌号 = "无";
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.TRUCKNO))
|
|
|
|
|
车牌号 = item.TRUCKNO;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var newrk = new List<DingTalkFormField>
|
|
|
|
|
{
|
|
|
|
|
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.AREANAME.ToString()),
|
|
|
|
|
new DingTalkFormField("车队", 车队),
|
|
|
|
|
new DingTalkFormField("车牌号", 车牌号),
|
|
|
|
|
new DingTalkFormField("唯一标识", item.GID)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
入库信息list.Add(newrk);
|
|
|
|
|
|
|
|
|
|
//if (车队list != null && 车队list.Exists(x => x.GID == item.CHEDUIID))
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// var 车队 = 车队list.First(x => x.GID == item.CHEDUIID);
|
|
|
|
|
// var newcl = new List<DingTalkFormField>{
|
|
|
|
|
// new DingTalkFormField("车队", 车队.SHORTNAME),
|
|
|
|
|
// new DingTalkFormField("车牌号", item.TRUCKNO)
|
|
|
|
|
// };
|
|
|
|
|
// 车队信息list.Add(newcl);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var newcl = new List<DingTalkFormField>{
|
|
|
|
|
// new DingTalkFormField("车队", "青岛众盈"),
|
|
|
|
|
// new DingTalkFormField("车牌号", "车牌号")
|
|
|
|
|
// };
|
|
|
|
|
//车队信息list.Add(newcl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var 入库信息 = new DingTalkFormField("入库信息", JsonConvert.SerializeObject(入库信息list));
|
|
|
|
|
|
|
|
|
|
//20230130 取消入库审核的车队信息
|
|
|
|
|
//var 车队信息 = new DingTalkFormField("车队信息", JsonConvert.SerializeObject(车队信息list));
|
|
|
|
|
|
|
|
|
|
body.formComponentValues = new List<DingTalkFormField>
|
|
|
|
|
{
|
|
|
|
|
//new DingTalkFormField("提单号", "123123")
|
|
|
|
|
//增加字段内容
|
|
|
|
|
new DingTalkFormField("客户名称", wms.CUSTOMERNAME),
|
|
|
|
|
new DingTalkFormField("入库日期", ((DateTime)wms.WMSDATE).ToString("yyyy-MM-dd")),
|
|
|
|
|
入库信息
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
jsonObj = body;
|
|
|
|
|
|
|
|
|
|
token = MemoryCache.Default[DingTalkTokenJob.DingTalkAccessTokenStoreKey].ToString();
|
|
|
|
|
url = $"https://api.dingtalk.com/v1.0/workflow/processInstances";
|
|
|
|
|
HeaderDic = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "x-acs-dingtalk-access-token", token }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result.OK();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
return result.SetErrorInfo(e.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DBResult DoSend()
|
|
|
|
|
{
|
|
|
|
|
var result = base.DoSend_Header();
|
|
|
|
|
|
|
|
|
|
if (result.Success)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var jo = new DingTalk_SendAuditResult();
|
|
|
|
|
|
|
|
|
|
jo = (DingTalk_SendAuditResult)JsonToObject(result.Data.ToString(), jo);
|
|
|
|
|
|
|
|
|
|
var dic = new Dictionary<string, string>();
|
|
|
|
|
dic.Add("instanceId", jo.instanceId);
|
|
|
|
|
|
|
|
|
|
BasicDataRefDAL.SaveLogicInfo(BSNO, "钉钉审批", dic);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class DingTalk_WmsOutAudit : DingTalk_SendAuditWork
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public DingTalk_WmsOutAudit(string uid)
|
|
|
|
|
{
|
|
|
|
|
this.uid = uid;
|
|
|
|
|
getUser();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override DBResult MakeSendMessage(string bsno)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
bsno = bsno.Replace("'", "");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(user.DingTalkAccount))
|
|
|
|
|
{
|
|
|
|
|
return result.SetErrorInfo("请配置用户的钉钉id");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BSNO = bsno;
|
|
|
|
|
|
|
|
|
|
DingTalk_OAAuditBody body = new DingTalk_OAAuditBody();
|
|
|
|
|
|
|
|
|
|
var 诚锐app = DingTalkApp.GetDingTalkApp("诚锐东胜对接");
|
|
|
|
|
|
|
|
|
|
var dp = 诚锐app.GetProcess("诚锐出货通知");
|
|
|
|
|
|
|
|
|
|
body.deptId = dp.deptid;//
|
|
|
|
|
//获取用户的钉钉id
|
|
|
|
|
var dtc = new DingTalkContext();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//body.approvers.Add(new DingTalkForm_approvers("OR", new List<string> { user.DingTalkAccount }));
|
|
|
|
|
body.microappAgentId = dp.agentid;//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
body.originatorUserId = user.DingTalkAccount;
|
|
|
|
|
body.processCode = dp.processCode;
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var wmsout = cdc.wms_out.First(p => p.BSNO == BSNO);
|
|
|
|
|
var wmsoutdetailList = cdc.wms_out_detail.Where(x => x.OUTBSNO == BSNO).ToList();
|
|
|
|
|
|
|
|
|
|
var 出库信息list = new List<List<DingTalkFormField>>();
|
|
|
|
|
var 车辆信息list = new List<List<DingTalkFormField>>();
|
|
|
|
|
|
|
|
|
|
var 待添加车辆信息=new List<wms_out_detail_md>();
|
|
|
|
|
|
|
|
|
|
var ingidlist= wmsoutdetailList.Select(s=>s.ASSOCIATEDNO).ToList();
|
|
|
|
|
var 对应入库wmsList = cdc.wms.Where(x => ingidlist.Contains(x.GID) || ingidlist.Contains(x.ASSOCIATEDNO)).ToList();
|
|
|
|
|
|
|
|
|
|
var wmsgidlist = 对应入库wmsList.Select(s => s.GID).ToList();
|
|
|
|
|
var 对应入库wmsinList = cdc.wms_in.Where(x => wmsgidlist.Contains(x.ASSOCIATEDNO)).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in wmsoutdetailList)
|
|
|
|
|
{
|
|
|
|
|
var 对应入库wms = 对应入库wmsList.First(x => x.GID == item.ASSOCIATEDNO || ingidlist.Contains(x.ASSOCIATEDNO));
|
|
|
|
|
|
|
|
|
|
var 对应入库wmsin = new wms_in_md();
|
|
|
|
|
|
|
|
|
|
if (item.ASSOCIATEDNO == item.INBSNO)
|
|
|
|
|
{
|
|
|
|
|
//整体出库 明细取第一条即可
|
|
|
|
|
对应入库wmsin = 对应入库wmsinList.First(x => x.ASSOCIATEDNO == item.ASSOCIATEDNO);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//明细出库 取具体条目
|
|
|
|
|
对应入库wmsin= 对应入库wmsinList.First(x => x.GID == item.INBSNO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//重量和尺码 都来自出库量字段GOODSPFSL 填充重量还是尺码 决定于chargeunit
|
|
|
|
|
|
|
|
|
|
var 重量 = 0M;
|
|
|
|
|
var 尺码 = 0M;
|
|
|
|
|
|
|
|
|
|
if (对应入库wms.CHARGEUNIT == "吨" || 对应入库wms.CHARGEUNIT == "千克") {
|
|
|
|
|
重量 = item.GOODSPFSL == null?0M:(decimal)item.GOODSPFSL;
|
|
|
|
|
}
|
|
|
|
|
if (对应入库wms.CHARGEUNIT == "CBM")
|
|
|
|
|
{
|
|
|
|
|
尺码 = item.GOODSPFSL == null ? 0M : (decimal)item.GOODSPFSL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cntrno = item.CntrNo;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(cntrno)) {
|
|
|
|
|
cntrno = 对应入库wmsin.CNTRNO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newrk = new List<DingTalkFormField>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
new DingTalkFormField("提单号", 对应入库wms.BLNO),
|
|
|
|
|
new DingTalkFormField("箱号", cntrno),
|
|
|
|
|
new DingTalkFormField("品名", item.GOODSNAME),
|
|
|
|
|
new DingTalkFormField("重量", 重量.ToString()),
|
|
|
|
|
new DingTalkFormField("件数", item.GOODSPACKPFSL.ToString()),
|
|
|
|
|
new DingTalkFormField("尺码", 尺码.ToString()),
|
|
|
|
|
new DingTalkFormField("库位", string.IsNullOrWhiteSpace(对应入库wmsin.AREANAME.ToString())?"无":对应入库wmsin.AREANAME.ToString()),
|
|
|
|
|
new DingTalkFormField("唯一标识", item.GID)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
出库信息list.Add(newrk);
|
|
|
|
|
|
|
|
|
|
if (待添加车辆信息.Exists(x => x.TRUCKNO == item.TRUCKNO)) {
|
|
|
|
|
if (待添加车辆信息.Exists(x => x.TRUCKNO == item.TRUCKNO && (x.DRIVERIDCARD != null && x.DRIVERIDCARD != "")))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
待添加车辆信息.First(x => x.TRUCKNO == item.TRUCKNO).DRIVERIDCARD = item.DRIVERIDCARD;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
待添加车辆信息.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (待添加车辆信息!=null && 待添加车辆信息.Count>0)
|
|
|
|
|
{
|
|
|
|
|
foreach(var item in 待添加车辆信息) {
|
|
|
|
|
|
|
|
|
|
var newcl = new List<DingTalkFormField>{
|
|
|
|
|
|
|
|
|
|
new DingTalkFormField("车牌号", item.TRUCKNO),
|
|
|
|
|
new DingTalkFormField("司机姓名", item.DRIVERIDCARD)
|
|
|
|
|
};
|
|
|
|
|
车辆信息list.Add(newcl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var 出库信息 = new DingTalkFormField("出库信息", JsonConvert.SerializeObject(出库信息list));
|
|
|
|
|
var 车辆信息 = new DingTalkFormField("车辆信息", JsonConvert.SerializeObject(车辆信息list));
|
|
|
|
|
|
|
|
|
|
body.formComponentValues = new List<DingTalkFormField>
|
|
|
|
|
{
|
|
|
|
|
//new DingTalkFormField("提单号", "123123")
|
|
|
|
|
//增加字段内容
|
|
|
|
|
new DingTalkFormField("客户名称", wmsout.CUSTOMERNAME),
|
|
|
|
|
new DingTalkFormField("出库日期", ((DateTime)wmsout.DODATE).ToString("yyyy-MM-dd")),
|
|
|
|
|
出库信息,
|
|
|
|
|
车辆信息
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonObj = body;
|
|
|
|
|
|
|
|
|
|
token = MemoryCache.Default[DingTalkTokenJob.DingTalkAccessTokenStoreKey].ToString();
|
|
|
|
|
url = $"https://api.dingtalk.com/v1.0/workflow/processInstances";
|
|
|
|
|
HeaderDic = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "x-acs-dingtalk-access-token", token }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result.OK();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
return result.SetErrorInfo(e.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DBResult DoSend()
|
|
|
|
|
{
|
|
|
|
|
var result = base.DoSend_Header();
|
|
|
|
|
|
|
|
|
|
if (result.Success)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var jo = new DingTalk_SendAuditResult();
|
|
|
|
|
|
|
|
|
|
jo = (DingTalk_SendAuditResult)JsonToObject(result.Data.ToString(), jo);
|
|
|
|
|
|
|
|
|
|
var dic = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "instanceId", jo.instanceId }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BasicDataRefDAL.SaveLogicInfo(BSNO, "钉钉审批", dic);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalk_Instanceinfo : DingTalkSendHelper {
|
|
|
|
|
public string instanceId { get; set; }
|
|
|
|
|
public DingTalk_Instanceinfo()
|
|
|
|
|
{
|
|
|
|
|
//this.uid = uid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult MakeSendMessage(string instanceId )
|
|
|
|
|
{
|
|
|
|
|
this.instanceId = instanceId;
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
jsonObj = null;
|
|
|
|
|
|
|
|
|
|
token = MemoryCache.Default[DingTalkTokenJob.DingTalkAccessTokenStoreKey].ToString();
|
|
|
|
|
url = $"https://api.dingtalk.com/v1.0/workflow/processInstances" ;
|
|
|
|
|
|
|
|
|
|
dicObj= new Dictionary<string, string> {
|
|
|
|
|
{"processInstanceId",instanceId }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
HeaderDic = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "x-acs-dingtalk-access-token", token }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result.OK();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DBResult DoSend()
|
|
|
|
|
{
|
|
|
|
|
var result = base.DoGet_Header_Param();
|
|
|
|
|
|
|
|
|
|
if (result.Success)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
BasicDataRefDAL.SaveLog(result.Data.ToString(), uid, "读取业务信息","返回");
|
|
|
|
|
|
|
|
|
|
//jo = (DingTalk_Instanceinfo)JsonToObject(result.Data.ToString(), jo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 处理钉钉回调返回值
|
|
|
|
|
public class DingTalkCallbackDealHelper
|
|
|
|
|
{
|
|
|
|
|
public string processInstanceId { get; set; }
|
|
|
|
|
public string processCode { get; set; }
|
|
|
|
|
public string type { get; set; }
|
|
|
|
|
public DingTalkCallbackDealHelper() { }
|
|
|
|
|
public DingTalkCallbackDealHelper(string instanceId) {
|
|
|
|
|
processInstanceId = instanceId;
|
|
|
|
|
}
|
|
|
|
|
public DingTalkCallbackDealHelper(CallBackInfo callbackinfo)
|
|
|
|
|
{
|
|
|
|
|
processInstanceId = callbackinfo.processInstanceId;
|
|
|
|
|
processCode = callbackinfo.processCode;
|
|
|
|
|
type = callbackinfo.type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 已不使用 改为在子类内各自实现
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DBResult ReadDingtalkInstanceinfo()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
//var userid=
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//如果是费用入账动作 且配置了钉钉审批入库 则调用
|
|
|
|
|
result = DingTalkHelper.DingTalk_Instanceinfo(processInstanceId);
|
|
|
|
|
|
|
|
|
|
DingTalkInstanceinfo di = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize<DingTalkInstanceinfo>(result.Data.ToString());
|
|
|
|
|
|
|
|
|
|
//根据内容修改wms和wmsin值
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var lv = BasicDataRefDAL.GetLogicHaveValue("钉钉审批", "instanceId", processInstanceId);
|
|
|
|
|
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<wms_in_md>();
|
|
|
|
|
//if (wms != null) {
|
|
|
|
|
// wmslist = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList();
|
|
|
|
|
//}
|
|
|
|
|
var updwmsinlist = new List<wms_in_md>();
|
|
|
|
|
var newwmsinlist = new List<wms_in_md>();
|
|
|
|
|
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 = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
updrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
//updrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
|
|
|
|
updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wms.CHARGEUNIT == "CBM")
|
|
|
|
|
{
|
|
|
|
|
updrec.GOODSRKSL = DingWmsin.getValue_decimal("尺码");
|
|
|
|
|
updrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
//updrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
|
|
|
|
updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
}
|
|
|
|
|
updrec.GOODSPACK = DingWmsin.getValue_decimal("件数");
|
|
|
|
|
|
|
|
|
|
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 = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
newrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
//newrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
newrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
|
|
|
|
newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
newrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wms.CHARGEUNIT == "CBM")
|
|
|
|
|
{
|
|
|
|
|
newrec.GOODSRKSL = DingWmsin.getValue_decimal("尺码");
|
|
|
|
|
newrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
//newrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
newrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
|
|
|
|
newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
newrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
}
|
|
|
|
|
newrec.GOODSPACK = DingWmsin.getValue_decimal("件数");
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string date { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string result { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string type { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string userId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class FormComponentValues
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string componentType { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 客户名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string name { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string bizAlias { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string id { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 众盈
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string value { get; set; }
|
|
|
|
|
|
|
|
|
|
public static List<row> GetRowValues(string value)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//用value值文本来解析成 行信息
|
|
|
|
|
var result = new List<row>();
|
|
|
|
|
|
|
|
|
|
if (value.Contains("\"rowValue\""))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var jarr = JArray.Parse(value);
|
|
|
|
|
foreach (var item in jarr)
|
|
|
|
|
{
|
|
|
|
|
var obj = item as JObject;
|
|
|
|
|
|
|
|
|
|
var row =JsonConvert.DeserializeObject<row>(obj.ToString());
|
|
|
|
|
result.Add(row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{ }
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Tasks
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string result { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string activityId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string finishTime { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string pcUrl { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string createTime { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string mobileUrl { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string userId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public long? taskId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string status { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Result
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string finishTime { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<string> attachedProcessInstanceIds { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string businessId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 邓羽提交的入库统计
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string title { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string originatorDeptId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<OperationRecords> operationRecords { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<FormComponentValues> formComponentValues { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string result { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string bizAction { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string createTime { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string originatorUserId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<Tasks> tasks { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 青岛诚锐众盈货运代理有限公司
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string originatorDeptName { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string status { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalkInstanceinfo
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Result result { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool success { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class 行信息
|
|
|
|
|
{
|
|
|
|
|
public List<row> row { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public class row
|
|
|
|
|
{
|
|
|
|
|
public List<rowValue> rowValue { get; set; }
|
|
|
|
|
public string rowNumber { get; set; }
|
|
|
|
|
public string getValue(string fieldname)
|
|
|
|
|
{
|
|
|
|
|
var result = "";
|
|
|
|
|
if (rowValue.Exists(x => x.label == fieldname))
|
|
|
|
|
{
|
|
|
|
|
result = rowValue.First(x => x.label == fieldname).value;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public decimal getValue_decimal(string fieldname)
|
|
|
|
|
{
|
|
|
|
|
var resultstr = "";
|
|
|
|
|
var result = 0M;
|
|
|
|
|
if (rowValue.Exists(x => x.label == fieldname))
|
|
|
|
|
{
|
|
|
|
|
resultstr = rowValue.First(x => x.label == fieldname).value;
|
|
|
|
|
}
|
|
|
|
|
//return result;
|
|
|
|
|
|
|
|
|
|
//提取带有小数点的数字,该方式会将所有带有小数的数字拼接在一起,如:"ABC#123.56@AS8.9测试"提取出来就是123.568.9
|
|
|
|
|
var result2 = Regex.Replace(resultstr, @"[^\d.\d]", "");
|
|
|
|
|
//如果是数字,则转换为decimal类型
|
|
|
|
|
if (Regex.IsMatch(result2, @"^[+-]?\d*[.]?\d*$"))
|
|
|
|
|
{
|
|
|
|
|
result = decimal.Parse(result2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class rowValue
|
|
|
|
|
{
|
|
|
|
|
public string bizAlias { get; set; }
|
|
|
|
|
public string label { get; set; }
|
|
|
|
|
public string value { get; set; }
|
|
|
|
|
public string key { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 钉钉业务类
|
|
|
|
|
|
|
|
|
|
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 static DingTalkApp GetDingTalkApp(string appname)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DingTalkApp();
|
|
|
|
|
if (appname == "ddlucky测试应用")
|
|
|
|
|
{
|
|
|
|
|
result = new DingTalkApp_ddlucky测试应用();
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (appname == "诚锐东胜对接")
|
|
|
|
|
{
|
|
|
|
|
result = new DingTalkApp_诚锐东胜对接();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual DingTalkProcess GetProcess(string processname) {
|
|
|
|
|
return new DingTalkProcess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual DingTalkProcess GetDingTalkProcessByProcessCode(string processcode)
|
|
|
|
|
{
|
|
|
|
|
return new DingTalkProcess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Getappinfo(ref DingTalkProcess process) {
|
|
|
|
|
process.token = token;
|
|
|
|
|
process.aes_key = aes_key;
|
|
|
|
|
process.appkey = appkey;
|
|
|
|
|
process.agentid = agentid;
|
|
|
|
|
process.deptid = deptid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class DingTalkApp_ddlucky测试应用 : DingTalkApp
|
|
|
|
|
{
|
|
|
|
|
public DingTalkApp_ddlucky测试应用() {
|
|
|
|
|
token = "zbGFOwrH6zCvq3VE3izLmWRTNUC1YcX";
|
|
|
|
|
aes_key = "sb6GkCKsUwNQo3RKbX1MzHKea1ZsE221n3xQ9hwJBMK";
|
|
|
|
|
appkey = "dingsaofiohmsrcbxyef";
|
|
|
|
|
agentid = 2298782307;
|
|
|
|
|
deptid = 809181118;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DingTalkProcess GetProcess(string processname)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DingTalkProcess();
|
|
|
|
|
if (processname == "测试入货通知")
|
|
|
|
|
{
|
|
|
|
|
result = new DingTalkProcess_测试入货通知(processname);
|
|
|
|
|
Getappinfo(ref result);
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DingTalkProcess GetDingTalkProcessByProcessCode(string processCode)
|
|
|
|
|
{
|
|
|
|
|
var processdic = new Dictionary<string, string> {
|
|
|
|
|
{ "PROC-0DC40EA2-E9D2-4917-A597-AD77EC055C49","测试入货通知"}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (processdic.ContainsKey(processCode))
|
|
|
|
|
{
|
|
|
|
|
return GetProcess(processdic[processCode]);
|
|
|
|
|
}
|
|
|
|
|
else { return new DingTalkProcess(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalkApp_诚锐东胜对接 : DingTalkApp
|
|
|
|
|
{
|
|
|
|
|
public DingTalkApp_诚锐东胜对接()
|
|
|
|
|
{
|
|
|
|
|
token = "CWhvNvfyuNf9D8halMs5PyHV70CrFx3E";
|
|
|
|
|
aes_key = "O5u6L8YnUaucnC8FyFNMeMeGE5uoYSAGFGdg3rOHftt";
|
|
|
|
|
appkey = "dingkt5caipnn4fbuqsf";
|
|
|
|
|
agentid = 2365401074;
|
|
|
|
|
deptid = 432400353;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DingTalkProcess GetProcess(string processname)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DingTalkProcess();
|
|
|
|
|
if (processname == "诚锐入货通知")
|
|
|
|
|
{
|
|
|
|
|
result = new DingTalkProcess_诚锐入库(processname);
|
|
|
|
|
Getappinfo(ref result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (processname == "诚锐出货通知")
|
|
|
|
|
{
|
|
|
|
|
result = new DingTalkProcess_诚锐出库(processname);
|
|
|
|
|
Getappinfo(ref result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DingTalkProcess GetDingTalkProcessByProcessCode(string processCode)
|
|
|
|
|
{
|
|
|
|
|
var processdic = new Dictionary<string, string> {
|
|
|
|
|
{ "PROC-0888A19C-0562-42AC-A9C6-24E4C4398410","诚锐入货通知"},
|
|
|
|
|
{ "PROC-7F3CA810-FB06-4E59-867F-49C42BFC25FB","诚锐出货通知"}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (processdic.ContainsKey(processCode))
|
|
|
|
|
{
|
|
|
|
|
return GetProcess(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; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 这些数值来自于钉钉中某个组织的某个应用。一个应用可以监听多个实际业务的返回值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="processname"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual DBResult DoDeal() { return new DBResult(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DingTalkProcess_测试入货通知 : DingTalkProcess
|
|
|
|
|
{
|
|
|
|
|
public DingTalkProcess_测试入货通知(string processname)
|
|
|
|
|
{
|
|
|
|
|
this.processname = processname;
|
|
|
|
|
|
|
|
|
|
//token = "zbGFOwrH6zCvq3VE3izLmWRTNUC1YcX";
|
|
|
|
|
//aes_key = "sb6GkCKsUwNQo3RKbX1MzHKea1ZsE221n3xQ9hwJBMK";
|
|
|
|
|
//appkey = "dingsaofiohmsrcbxyef";
|
|
|
|
|
//agentid = 2298782307;
|
|
|
|
|
|
|
|
|
|
processCode = "PROC-0DC40EA2-E9D2-4917-A597-AD77EC055C49";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override DBResult DoDeal() {
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
//根据processinstancid 读取审批实例信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var 返回结果Str = DingTalkHelper.DingTalk_Instanceinfo(callbackinfo.processInstanceId);
|
|
|
|
|
|
|
|
|
|
//解析返回结果
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class DingTalkProcess_诚锐入库 : DingTalkProcess
|
|
|
|
|
{
|
|
|
|
|
public DingTalkProcess_诚锐入库(string processname) {
|
|
|
|
|
this.processname = processname;
|
|
|
|
|
|
|
|
|
|
//token = "CWhvNvfyuNf9D8halMs5PyHV70CrFx3E";
|
|
|
|
|
//aes_key = "O5u6L8YnUaucnC8FyFNMeMeGE5uoYSAGFGdg3rOHftt";
|
|
|
|
|
//appkey = "dingkt5caipnn4fbuqsf";
|
|
|
|
|
//agentid = 2365401074;
|
|
|
|
|
|
|
|
|
|
processCode = "PROC-0888A19C-0562-42AC-A9C6-24E4C4398410";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DBResult DoDeal()
|
|
|
|
|
{
|
|
|
|
|
//return new DBResult();
|
|
|
|
|
|
|
|
|
|
if (callbackinfo.type == "finish")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return ReadDingtalkInstanceinfo(callbackinfo.processInstanceId);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return new DBResult();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult ReadDingtalkInstanceinfo(string processInstanceId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
//var userid=
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//如果是费用入账动作 且配置了钉钉审批入库 则调用
|
|
|
|
|
result = DingTalkHelper.DingTalk_Instanceinfo(processInstanceId);
|
|
|
|
|
|
|
|
|
|
DingTalkInstanceinfo di = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize<DingTalkInstanceinfo>(result.Data.ToString());
|
|
|
|
|
|
|
|
|
|
//根据内容修改wms和wmsin值
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var lv = BasicDataRefDAL.GetLogicHaveValue("钉钉审批", "instanceId", processInstanceId);
|
|
|
|
|
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<wms_in_md>();
|
|
|
|
|
//if (wms != null) {
|
|
|
|
|
// wmslist = cdc.wms_in.Where(x => x.ASSOCIATEDNO == wms.GID).ToList();
|
|
|
|
|
//}
|
|
|
|
|
var updwmsinlist = new List<wms_in_md>();
|
|
|
|
|
var newwmsinlist = new List<wms_in_md>();
|
|
|
|
|
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);
|
|
|
|
|
wms.STARTBILLINGDATE= Convert.ToDateTime(item.value);
|
|
|
|
|
wms.STARTBILLINGDATEAP = 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("箱号");
|
|
|
|
|
var wmsingid= DingWmsin.getValue("唯一标识");
|
|
|
|
|
if (wmslist.Exists(x => x.GID== wmsingid))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var updrec = wmslist.First(x => x.GID == wmsingid);
|
|
|
|
|
|
|
|
|
|
//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.BLNO = DingWmsin.getValue("提单号");
|
|
|
|
|
updrec.CNTRNO = DingWmsin.getValue("箱号");
|
|
|
|
|
updrec.GOODSNAME = DingWmsin.getValue("品名");
|
|
|
|
|
|
|
|
|
|
if (wms.CHARGEUNIT == "吨" || wms.CHARGEUNIT == "千克")
|
|
|
|
|
{
|
|
|
|
|
updrec.GOODSRKSL = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
updrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
updrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue_decimal("重量"));
|
|
|
|
|
|
|
|
|
|
updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue_decimal("尺码"));
|
|
|
|
|
updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue_decimal("尺码"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wms.CHARGEUNIT == "CBM")
|
|
|
|
|
{
|
|
|
|
|
updrec.GOODSRKSL = DingWmsin.getValue_decimal("尺码");
|
|
|
|
|
updrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
updrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
updrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
|
|
|
|
updrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
updrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
}
|
|
|
|
|
updrec.GOODSPACK = DingWmsin.getValue_decimal("件数");
|
|
|
|
|
|
|
|
|
|
updrec.AREANAME = DingWmsin.getValue("库位");
|
|
|
|
|
updrec.DODATE = wms.WMSDATE;
|
|
|
|
|
|
|
|
|
|
//if(string.IsNullOrWhiteSpace(DingWmsin.getValue("车牌号")))
|
|
|
|
|
updrec.TRUCKNO = DingWmsin.getValue("车牌号");
|
|
|
|
|
|
|
|
|
|
var 车队name= DingWmsin.getValue("车队");
|
|
|
|
|
var 车队infoclient = cdc.info_client.FirstOrDefault(x => x.SHORTNAME == 车队name);
|
|
|
|
|
|
|
|
|
|
if(车队infoclient!=null && !string.IsNullOrWhiteSpace( 车队infoclient.SHORTNAME))
|
|
|
|
|
updrec.CHEDUIID = 车队infoclient.GID;
|
|
|
|
|
|
|
|
|
|
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 = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
newrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
newrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
newrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
|
|
|
|
newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
newrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wms.CHARGEUNIT == "CBM")
|
|
|
|
|
{
|
|
|
|
|
newrec.GOODSRKSL = DingWmsin.getValue_decimal("尺码");
|
|
|
|
|
newrec.GOODSSTOCK = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
newrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
newrec.SHIJIZHONGLIANG = Convert.ToDouble(DingWmsin.getValue("重量"));
|
|
|
|
|
|
|
|
|
|
newrec.CHIMA1 = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
newrec.SHIJICHIMA = Convert.ToDouble(DingWmsin.getValue("尺码"));
|
|
|
|
|
}
|
|
|
|
|
newrec.GOODSPACK = DingWmsin.getValue_decimal("件数");
|
|
|
|
|
newrec.AREANAME = DingWmsin.getValue("库位");
|
|
|
|
|
newrec.CREATETIME = DateTime.Now;
|
|
|
|
|
newrec.CHARGEUNIT = wms.CHARGEUNIT;
|
|
|
|
|
newrec.CORPID = wms.CORPID;
|
|
|
|
|
|
|
|
|
|
newrec.TRUCKNO = DingWmsin.getValue("车牌号");
|
|
|
|
|
|
|
|
|
|
var 车队name = DingWmsin.getValue("车队");
|
|
|
|
|
var 车队infoclient = cdc.info_client.FirstOrDefault(x => x.SHORTNAME == 车队name);
|
|
|
|
|
|
|
|
|
|
if (车队infoclient != null && string.IsNullOrWhiteSpace(车队infoclient.SHORTNAME))
|
|
|
|
|
newrec.CHEDUIID = 车队infoclient.SHORTNAME;
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
cdc.wms_in.AddOrUpdate(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//20230209 根据明细数据重新计算头表数据
|
|
|
|
|
var 件数 = updwmsinlist.Sum(s => s.GOODSPACK);
|
|
|
|
|
var 重量 = updwmsinlist.Sum(s => s.GOODSKGS);
|
|
|
|
|
var 入库量 = updwmsinlist.Sum(s => s.GOODSRKSL);
|
|
|
|
|
var 尺码 = updwmsinlist.Sum(s => s.CHIMA1);
|
|
|
|
|
|
|
|
|
|
wms.GOODSPACK = 件数;
|
|
|
|
|
wms.GOODSPACKSTOCK = 件数;
|
|
|
|
|
wms.GOODSPACKACTUAL = 件数;
|
|
|
|
|
|
|
|
|
|
wms.GOODSRKSL = 入库量;
|
|
|
|
|
wms.GOODSRKSLACTUAL = 入库量;
|
|
|
|
|
wms.GOODSSTOCK = 入库量;
|
|
|
|
|
wms.GOODSKGS = 重量;
|
|
|
|
|
|
|
|
|
|
cdc.wms.AddOrUpdate(wms);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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 DingTalkProcess_诚锐出库 : DingTalkProcess
|
|
|
|
|
{
|
|
|
|
|
public DingTalkProcess_诚锐出库(string processname)
|
|
|
|
|
{
|
|
|
|
|
this.processname = processname;
|
|
|
|
|
|
|
|
|
|
//token = "CWhvNvfyuNf9D8halMs5PyHV70CrFx3E";
|
|
|
|
|
//aes_key = "O5u6L8YnUaucnC8FyFNMeMeGE5uoYSAGFGdg3rOHftt";
|
|
|
|
|
//appkey = "dingkt5caipnn4fbuqsf";
|
|
|
|
|
//agentid = 2365401074;
|
|
|
|
|
|
|
|
|
|
processCode = "PROC-7F3CA810-FB06-4E59-867F-49C42BFC25FB";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override DBResult DoDeal()
|
|
|
|
|
{
|
|
|
|
|
//return new DBResult();
|
|
|
|
|
if (callbackinfo.type == "finish")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return ReadDingtalkInstanceinfo(callbackinfo.processInstanceId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return new DBResult();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DBResult ReadDingtalkInstanceinfo(string processInstanceId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
//var userid=
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
result = DingTalkHelper.DingTalk_Instanceinfo(processInstanceId);
|
|
|
|
|
|
|
|
|
|
DingTalkInstanceinfo di = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize<DingTalkInstanceinfo>(result.Data.ToString());
|
|
|
|
|
|
|
|
|
|
//根据内容修改wms_out_detail的值
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var lv = BasicDataRefDAL.GetLogicHaveValue("钉钉审批", "instanceId", processInstanceId);
|
|
|
|
|
if (lv != null && lv.ContainsKey("instanceId"))
|
|
|
|
|
{
|
|
|
|
|
var BSNO = lv["BSNO"];
|
|
|
|
|
|
|
|
|
|
var wmsold = new DSWeb.MvcShipping.Models.WMS.WMS_OUT_OLD(BSNO);
|
|
|
|
|
var wms_out = wmsold.wms_out;
|
|
|
|
|
var wms_out_detaillist = wmsold.wms_out_detail;
|
|
|
|
|
|
|
|
|
|
List<wms_out_detail_md> updwmslist = new List<wms_out_detail_md>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_out.DODATE = Convert.ToDateTime(item.value);
|
|
|
|
|
cdc.wms_out.AddOrUpdate(wms_out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item.name == "出库信息")
|
|
|
|
|
{
|
|
|
|
|
var 出库信息list = FormComponentValues.GetRowValues(item.value);
|
|
|
|
|
if (出库信息list != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var DingWmsin in 出库信息list)
|
|
|
|
|
{
|
|
|
|
|
//var 提单号 = DingWmsin.getValue("提单号");
|
|
|
|
|
//var 箱号 = DingWmsin.getValue("箱号");
|
|
|
|
|
//var 品名 = DingWmsin.getValue("品名");
|
|
|
|
|
var gid= DingWmsin.getValue("唯一标识");
|
|
|
|
|
|
|
|
|
|
if (wmsold.VW_WMS_OUT_DETAIL.Exists(x => x.GID_OUT == gid))
|
|
|
|
|
{
|
|
|
|
|
//var _outrec= wmsold.VW_WMS_OUT_DETAIL.First(x => x.GID_OUT == gid);
|
|
|
|
|
var updrec = wms_out_detaillist.First(x => x.GID== gid);
|
|
|
|
|
|
|
|
|
|
//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_out.CHARGEUNIT == "吨" || wms_out.CHARGEUNIT == "千克")
|
|
|
|
|
{
|
|
|
|
|
updrec.GOODSPFSL = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
updrec.GOODSKGS = DingWmsin.getValue_decimal("重量");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wms_out.CHARGEUNIT == "CBM")
|
|
|
|
|
{
|
|
|
|
|
updrec.GOODSPFSL = DingWmsin.getValue_decimal("尺码");
|
|
|
|
|
updrec.GOODSKGS =0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
updrec.GOODSPACK = DingWmsin.getValue("件数");
|
|
|
|
|
|
|
|
|
|
//updrec.AREANAME = DingWmsin.getValue("库位");
|
|
|
|
|
//updrec.DODATE = wms_out.DODATE;
|
|
|
|
|
updwmslist.Add(updrec);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.name == "车辆信息")
|
|
|
|
|
{
|
|
|
|
|
var 车队信息list = FormComponentValues.GetRowValues(item.value);
|
|
|
|
|
if (车队信息list != null && 车队信息list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
车辆信息.TRUCKNO = 车队信息list[0].getValue("车牌号");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//cdc.wms.AddOrUpdate(wms);
|
|
|
|
|
if (updwmslist != null && updwmslist.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in updwmslist)
|
|
|
|
|
{
|
|
|
|
|
//item.CHEDUIID = 车辆信息.CHEDUIID;
|
|
|
|
|
item.TRUCKNO = 车辆信息.TRUCKNO;
|
|
|
|
|
cdc.wms_out_detail.AddOrUpdate(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
|
|
|
|
|
//20230221 根据明细总数合计一下原业务的合计数
|
|
|
|
|
wms_out.SetSum(updwmslist);
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
|
|
|
|
|
//然后执行出库的费用入账原逻辑
|
|
|
|
|
|
|
|
|
|
var outtype = wms_out.IsDetail == "1" ? "StockOutDetail" : "StockOut";
|
|
|
|
|
|
|
|
|
|
DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL.WMSOUT_GuiGeDAL.DoSetislock(wms_out.GID, (bool)wms_out.EIP, outtype,wms_out.CREATEUSER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo(e.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|