旧仓储出库的钉钉审核部分,如果设为钉钉审核,则点击费用入账后提交钉钉,钉钉审核后实际执行费用入账。

DS7_JinGang
ddlucky 2 years ago
parent 63e756e13d
commit 314f83cf68

@ -2243,6 +2243,20 @@ namespace DSWeb.Common.DB
public string GOODSCKQSTOCK { get; set; }
}
/// <summary>
/// 暂时只用于查询出库相关库存在入库单和入库单明细中的提单号箱号
/// </summary>
[Table("VW_WMS_OUT_DETAIL")]
public partial class VW_WMS_OUT_DETAIL_md
{
[Key]
public string GID_OUT { get; set; }
public string BLNO { get; set; }
public string CNTRNO { get; set; }
public string GOODSNAME_OUT { get; set; }
}
public static class StrHelper
{
#region 将一个dictionary转化为用;;和::隔开的文本

@ -73,6 +73,7 @@ namespace DSWeb.Common.DB
public DbSet<wms_in_md> wms_in { get; set; }
public DbSet<wms_out_md> wms_out { get; set; }
public DbSet<wms_out_detail_md> wms_out_detail { get; set; }
public DbSet<VW_WMS_OUT_DETAIL_md> VW_WMS_OUT_DETAIL { get; set; }
}

@ -22,12 +22,13 @@ using Ivony.Fluent;
using DSWeb.MvcShipping.DAL.WMSStock;
using System.Configuration;
using DSWeb.Areas.MvcShipping.Helper;
using NPOI.HSSF.Record;
namespace DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL
{
public class WMSOUT_GuiGeDAL
{
#region 查询主表
#region 出库管理(规格) 查询主表
static public List<WMSOUT_GuiGe> GetDataListHJ(string strCondition, string userid, string usercode, string companyid, int start=0, int limit=10000, string sort = null)
{
@ -1890,12 +1891,93 @@ namespace DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL
result.Success = false;
result.Message = "没有输入任何需要修改的数据";
}
gids = "'" + gids.Trim().Replace(",", "','") + "'";
#region 费用入账
Database db = DatabaseFactory.CreateDatabase();
//20230128 改为
if (ConfigurationManager.AppSettings["DingTalkAuditWMSIN"] == "true")
{//向钉钉发送出库审批流程
var _r0 = new DBResult();
_r0.OK();
//如果是费用入账动作 且配置了钉钉审批入库 则调用向钉钉发送新建审批实例方法
var strSql = new StringBuilder();
strSql.Append("select o.IsDetail AS ISDETAIL,d.inbsno as INBSNO,o.gid as OUTGID,o.bsno as OUTNO,o.ASSOCIATEDNO AS ASSOCIATEDNO, ");
strSql.Append(" o.ARCLIENTWMSOUT as ARCLIENTWMSOUT,isnull(d.GOODSOUTFEE,0) AS GOODSOUTFEE_OUT,");
strSql.Append(" o.TRUCKNAME as TRUCKNAME_OUT,isnull(d.GOODSOUTFEEAP,0) AS GOODSOUTFEEAP_OUT,");
strSql.Append(" isnull(d.ARFEE,0) AS ARFEE_OUT,isnull(d.ARFEE_2,0) AS ARFEE_2_OUT,d.GID OUTDEGID");
strSql.Append(" ,ol.PROPVALUE");
strSql.Append(" from wms_out o inner join wms_out_detail d on o.bsno = d.outbsno ");
strSql.Append(" left join OP_LOGICINFO ol on ol.BSNO=o.bsno ");
strSql.Append(" where o.gid in (" + gids + ") and o.ISLOCK=0");
//var 需要发送给钉钉出库审核流程的业务编号List = new List<string>();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var outbsno = Convert.ToString(reader["OUTNO"]);
var instanceId = Convert.ToString(reader["PROPVALUE"]);
if (!string.IsNullOrWhiteSpace(instanceId)) continue;
var _r = DingTalkHelper.Send_WMSOUT(strUserID, outbsno);
if (!_r.Success)
{
_r0.SetErrorInfo(_r.Message);
}
//仅用于测试解析读取钉钉审批实例内容
//result = TestReadDingtalkInstanceinfo();
if (!_r0.Success)
{
result.Success = false;
result.Message = "发送钉钉审批失败:" + _r0.Message;
return result;
}
else
{
//增加一条钉钉审批记录
}
}
}
return result;
}
else {
return DoSetislock(gids, bEIP, outType, strUserID, strCompanyID, strDEPTNAME, strSHOWNAME);
}
}
/// <summary>
/// 实际执行费用入账操作
/// </summary>
/// <param name="gids">wms_out.GID 用逗号,隔开</param>
/// <param name="bEIP">bool型 wms_out.EIP</param>
/// <param name="outType">StockOut、StockOutDetail,来自wms_out.ISDETAIL true=StockOutDetail false=StockOut</param>
/// <param name="strUserID">调用时可使用wms_out.CREATEUSER</param>
/// <param name="strCompanyID">未使用 不填</param>
/// <param name="strDEPTNAME">未使用 不填</param>
/// <param name="strSHOWNAME">未使用 不填</param>
/// <returns></returns>
public static DBResult DoSetislock(string gids, bool bEIP, string outType, string strUserID, string strCompanyID = "", string strDEPTNAME = "", string strSHOWNAME = "")
{
DBResult result = new DBResult();
if (gids.Trim() == "")
{
result.Success = false;
result.Message = "没有输入任何需要修改的数据";
}
Database db = DatabaseFactory.CreateDatabase();
gids = "'" + gids.Trim().Replace(",", "','") + "'";
#region 费用入账
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
@ -1908,8 +1990,6 @@ namespace DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL
strSql.Append(" from wms_out o inner join wms_out_detail d on o.bsno = d.outbsno ");
strSql.Append(" where o.gid in (" + gids + ") and o.ISLOCK=0");
var List = new List<string>();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
int i = 0;
@ -1988,9 +2068,7 @@ namespace DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL
#endregion
if (!List.Exists(x => x == outFee.OUTNO)) {
List.Add(outFee.OUTNO);
}
}
@ -2023,26 +2101,7 @@ namespace DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL
#endregion
}
if (ConfigurationManager.AppSettings["DingTalkAuditWMSIN"] == "true" )
{//向钉钉发送出库审批流程
var _r0 = new DBResult();
_r0.OK();
//如果是费用入账动作 且配置了钉钉审批入库 则调用向钉钉发送新建审批实例方法
foreach (var outbsno in List) {
var _r = DingTalkHelper.Send_WMSOUT(strUserID, outbsno);
if (!_r.Success) {
_r0.SetErrorInfo(_r.Message);
}
}
//仅用于测试解析读取钉钉审批实例内容
//result = TestReadDingtalkInstanceinfo();
if (!_r0.Success) {
result.Success = false;
result.Message = "发送钉钉审批失败:"+_r0.Message;
}
}
}
catch (Exception)
{

@ -687,11 +687,16 @@ namespace DSWeb.Areas.MvcShipping.Helper
= 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("箱号", 对应入库wmsin.CNTRNO),
new DingTalkFormField("箱号", cntrno),
new DingTalkFormField("品名", item.GOODSNAME),
new DingTalkFormField("重量", .ToString()),
new DingTalkFormField("件数", item.GOODSPACKPFSL.ToString()),
@ -774,8 +779,10 @@ namespace DSWeb.Areas.MvcShipping.Helper
jo = (DingTalk_SendAuditResult)JsonToObject(result.Data.ToString(), jo);
var dic = new Dictionary<string, string>();
dic.Add("instanceId", jo.instanceId);
var dic = new Dictionary<string, string>
{
{ "instanceId", jo.instanceId }
};
BasicDataRefDAL.SaveLogicInfo(BSNO, "钉钉审批", dic);
}
@ -863,6 +870,10 @@ namespace DSWeb.Areas.MvcShipping.Helper
type = callbackinfo.type;
}
/// <summary>
/// 已不使用 改为在子类内各自实现
/// </summary>
/// <returns></returns>
public DBResult ReadDingtalkInstanceinfo()
{
@ -1444,8 +1455,10 @@ namespace DSWeb.Areas.MvcShipping.Helper
public override DBResult DoDeal() {
var result = new DBResult();
//根据processinstancid 读取审批实例信息
var Str = DingTalkHelper.DingTalk_Instanceinfo(callbackinfo.processInstanceId);
var Str = DingTalkHelper.DingTalk_Instanceinfo(callbackinfo.processInstanceId);
//解析返回结果
@ -1469,7 +1482,208 @@ namespace DSWeb.Areas.MvcShipping.Helper
public override DBResult DoDeal()
{
//return new DBResult();
return callbackinfo.ReadDingtalkInstanceinfo();
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);
}
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 DingTalkProcess_ : DingTalkProcess
@ -1487,11 +1701,158 @@ namespace DSWeb.Areas.MvcShipping.Helper
}
//public override DBResult DoDeal()
//{
// //return new DBResult();
// //return callbackinfo.ReadDingtalkInstanceinfo();
//}
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.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("箱号");
var = DingWmsin.getValue("品名");
if (wmsold.VW_WMS_OUT_DETAIL.Exists(x => x.BLNO == && x.CNTRNO == && x.GOODSNAME_OUT == ))
{
var _outrec= wmsold.VW_WMS_OUT_DETAIL.First(x => x.BLNO == && x.CNTRNO == && x.GOODSNAME_OUT == );
var updrec = wms_out_detaillist.First(x => x.GID== _outrec.GID_OUT);
//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 = Convert.ToDecimal(DingWmsin.getValue("重量"));
updrec.GOODSKGS = Convert.ToDecimal(DingWmsin.getValue("重量"));
}
if (wms_out.CHARGEUNIT == "CBM")
{
updrec.GOODSPFSL = Convert.ToDecimal(DingWmsin.getValue("尺码"));
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)
{
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 (updwmslist != null && updwmslist.Count > 0)
{
foreach (var item in updwmslist)
{
//item.CHEDUIID = 车辆信息.CHEDUIID;
item.TRUCKNO = .TRUCKNO;
cdc.wms_out_detail.AddOrUpdate(item);
}
}
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

@ -3010,6 +3010,32 @@ namespace DSWeb.MvcShipping.Models.WMS
}
}
public class WMS_OUT_OLD
{
public wms_out_md wms_out { get; set; }
public List<wms_out_detail_md> wms_out_detail { get; set; }
public List<VW_WMS_OUT_DETAIL_md> VW_WMS_OUT_DETAIL { get; set; }
public WMS_OUT_OLD() { }
public WMS_OUT_OLD(string bsno)
{
var cdc = new CommonDataContext();
wms_out = cdc.wms_out.FirstOrDefault(x => x.BSNO == bsno);
if (wms_out != null)
{
wms_out_detail = cdc.wms_out_detail.Where(x => x.OUTBSNO == wms_out.BSNO).ToList();
var gids = wms_out_detail.Select(s => s.GID).ToList();
VW_WMS_OUT_DETAIL = cdc.VW_WMS_OUT_DETAIL.Where(x => gids.Contains(x.GID_OUT)).ToList();
}
}
}
#region 新的仓储数据结构
public class WMSIN_mb { }

@ -696,7 +696,6 @@ Ext.extend(Shipping.WMSOUT_GuiGeIndex, Ext.Panel, {
} else {
this.outType = "StockOut";
DsOpenEditWin('/MvcShipping/WMSOUT_GuiGe/Edit', "货权转移-出库单");
}
}

Loading…
Cancel
Save