|
|
|
@ -0,0 +1,681 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.Common;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpVgmSend;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsChFee;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.Comm;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using System.Data.Entity.Migrations;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpSeae;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using Quartz.Util;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsOpVgmSendDAL
|
|
|
|
|
{
|
|
|
|
|
public class MsOpVgmSendDAL
|
|
|
|
|
{
|
|
|
|
|
#region Inquery DataList
|
|
|
|
|
static public List<MsOpVgmSend> GetDataList(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT *,(select top 1 showname from [user] where GID=op_seae_vgm_send.SENDERUSER) as SENDERUSERREF FROM op_seae_vgm_send ";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT *,(select top 1 showname from [user] where GID=op_seae_vgm_send.SENDERUSER) as SENDERUSERREF FROM op_seae_vgm_send ";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsOpVgmSend GetData(string condition)
|
|
|
|
|
{
|
|
|
|
|
String strSql = "SELECT *,(select top 1 showname from [user] where GID=op_seae_vgm_send.SENDERUSER) as SENDERUSERREF FROM op_seae_vgm_send ";
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + condition;
|
|
|
|
|
}
|
|
|
|
|
var list = SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return list[0];
|
|
|
|
|
}
|
|
|
|
|
return new MsOpVgmSend();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MsOpVgmSend> SetData(String strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsOpVgmSend>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsOpVgmSend data = new MsOpVgmSend();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.VGMSTATUS = Convert.ToString(reader["VGMSTATUS"]);
|
|
|
|
|
data.MFNO = Convert.ToString(reader["MFNO"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
data.ORDERNO = Convert.ToString(reader["ORDERNO"]);
|
|
|
|
|
data.CARRIER = Convert.ToString(reader["CARRIER"]);
|
|
|
|
|
data.LOADPORT = Convert.ToString(reader["LOADPORT"]);
|
|
|
|
|
data.MATOU = Convert.ToString(reader["MATOU"]);
|
|
|
|
|
data.VESSEL = Convert.ToString(reader["VESSEL"]);
|
|
|
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
|
|
|
data.CARRIERSTATUS = Convert.ToString(reader["CARRIERSTATUS"]);
|
|
|
|
|
data.YGTSTATUS = Convert.ToString(reader["YGTSTATUS"]);
|
|
|
|
|
data.YARDSTATUS = Convert.ToString(reader["YARDSTATUS"]);
|
|
|
|
|
|
|
|
|
|
data.VGM_TIME = Convert.ToString(reader["VGM_TIME"]);
|
|
|
|
|
data.SENDERUSER = Convert.ToString(reader["SENDERUSER"]);
|
|
|
|
|
data.SENDERUSERREF = Convert.ToString(reader["SENDERUSERREF"]);
|
|
|
|
|
if (reader["CTNNUM"] != DBNull.Value)
|
|
|
|
|
data.CTNNUM = Convert.ToInt16(reader["CTNNUM"]);
|
|
|
|
|
if (reader["ISCARRIER"] != DBNull.Value)
|
|
|
|
|
data.ISCARRIER = Convert.ToBoolean(reader["ISCARRIER"]);
|
|
|
|
|
if (reader["ISYGT"] != DBNull.Value)
|
|
|
|
|
data.ISYGT = Convert.ToBoolean(reader["ISYGT"]);
|
|
|
|
|
|
|
|
|
|
if (reader["SENDTIME"] != DBNull.Value)
|
|
|
|
|
data.SENDTIME = Convert.ToDateTime(reader["SENDTIME"]);
|
|
|
|
|
|
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
|
|
|
|
|
|
data.LINKURL = Convert.ToString(reader["LINKURL"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 明细表
|
|
|
|
|
|
|
|
|
|
static public List<MsOpVgmCtn> GetVgmCtnList(string strCondition, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append("*");
|
|
|
|
|
strSql.Append(" from op_seae_vgm_ctn ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" WHERE " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by CTNALL ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SetVgmCtnData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<MsOpVgmCtn> SetVgmCtnData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsOpVgmCtn>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsOpVgmCtn data = new MsOpVgmCtn();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.CTN_ID = Convert.ToString(reader["CTN_ID"]);
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.CTNALL = Convert.ToString(reader["CTNALL"]);
|
|
|
|
|
data.SENDGID = Convert.ToString(reader["SENDGID"]);
|
|
|
|
|
data.CNTRNO = Convert.ToString(reader["CNTRNO"]);
|
|
|
|
|
data.SEALNO = Convert.ToString(reader["SEALNO"]);
|
|
|
|
|
data.WEIGHTYPE = Convert.ToString(reader["WEIGHTYPE"]);
|
|
|
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
|
|
|
data.WEIGHDATE = Convert.ToString(reader["WEIGHDATE"]);
|
|
|
|
|
if (reader["KGS"] != DBNull.Value)
|
|
|
|
|
data.KGS = Convert.ToDecimal(reader["KGS"]);//
|
|
|
|
|
|
|
|
|
|
if (reader["TAREWEIGHT"] != DBNull.Value)
|
|
|
|
|
data.TAREWEIGHT = Convert.ToDecimal(reader["TAREWEIGHT"]);//
|
|
|
|
|
if (reader["VGMKGS"] != DBNull.Value)
|
|
|
|
|
data.VGMKGS = Convert.ToDecimal(reader["VGMKGS"]);//
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult SaveDetail(string LE_ID, List<MsOpVgmCtn> bodyList)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var cmddelete = db.GetSqlStringCommand(@"delete from op_seae_vgm_ctn where SENDGID='" + LE_ID + "'");
|
|
|
|
|
db.ExecuteNonQuery(cmddelete, tran);
|
|
|
|
|
|
|
|
|
|
var cntr = "";
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
var cmdInsert = db.GetSqlStringCommand(@"insert into op_seae_vgm_ctn ([CTN_ID],[BSNO],[SENDGID],[CTNALL],[CNTRNO],[SEALNO],[KGS],[TAREWEIGHT],[WEIGHTYPE],[VGMKGS],[YARD],[WEIGHDATE])
|
|
|
|
|
values (NEWID(),'" + enumValue.BSNO + "','" + LE_ID + "','" + enumValue.CTNALL + "','" + enumValue.CNTRNO + "','" + enumValue.SEALNO + "'," + enumValue.KGS + "," + enumValue.TAREWEIGHT + ",'" + enumValue.WEIGHTYPE + "'," + enumValue.VGMKGS + ",'" + enumValue.YARD + "','" + enumValue.WEIGHDATE + "')");
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DsVgm CreateDjyVgm(MsOpVgmSend headData, List<MsOpVgmCtn> bodyList, MsOpSeae OpSeaehead)
|
|
|
|
|
{
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var DsVgm = new DsVgm();
|
|
|
|
|
DsVgm.mfno = headData.MFNO;
|
|
|
|
|
DsVgm.mblno = headData.MBLNO;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DsVgm.carrier = BasicDataRefDAL.GetCustEdiCodeByName2(OpSeaehead.CARRIER, "DJY");
|
|
|
|
|
//DsVgm.carrier = headData.CARRIER;
|
|
|
|
|
|
|
|
|
|
DsVgm.etd = OpSeaehead.ETD;
|
|
|
|
|
DsVgm.weiTuoFaSongFang = BasicDataRefDAL.GetCustEdiCodeByName2(OpSeaehead.CUSTOMERNAME, "DJY");
|
|
|
|
|
|
|
|
|
|
DsVgm.chuanMing = headData.CARRIER;
|
|
|
|
|
DsVgm.vsid = OpSeaehead.VESSELID;
|
|
|
|
|
|
|
|
|
|
DsVgm.hangCi = headData.VOYNO;
|
|
|
|
|
|
|
|
|
|
DsVgm.beiZhu = headData.REMARK;
|
|
|
|
|
|
|
|
|
|
//var 装货港 = OpSeaehead.PORTLOAD;
|
|
|
|
|
var 装货港代码 = headData.LOADPORT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//BasicDataRefDAL.GetPORTInfoByEDICODEAndEDIName("DJY", headData.LOADPORT, OpSeaehead.PORTLOAD, ref 装货港代码, ref 装货港);
|
|
|
|
|
|
|
|
|
|
var 口岸 = cdc.tSysEnumValue.Where(x => x.EnumTypeID == 96303 && x.EnumValueID == 装货港代码).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (口岸 != null) {
|
|
|
|
|
DsVgm.zhuangHuoGang = 口岸.EnumValueName;
|
|
|
|
|
DsVgm.zhuangHuoGangDaiMa = 口岸.EnumValueID;
|
|
|
|
|
}
|
|
|
|
|
DsVgm.yard = BasicDataRefDAL.GetCustEdiCodeByName2(OpSeaehead.YARD, "DJY");
|
|
|
|
|
|
|
|
|
|
DsVgm.orderno = headData.ORDERNO;
|
|
|
|
|
|
|
|
|
|
DsVgm.vgmclosetime = headData.VGM_TIME;
|
|
|
|
|
|
|
|
|
|
DsVgm.vgmclosetime = string.IsNullOrWhiteSpace(DsVgm.vgmclosetime) ? null : DsVgm.vgmclosetime;
|
|
|
|
|
|
|
|
|
|
DsVgm.wharf = headData.MATOU;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cntrlist = new List<Ctn>();
|
|
|
|
|
foreach (var ctn in bodyList)
|
|
|
|
|
{
|
|
|
|
|
var cntr = new Ctn();
|
|
|
|
|
cntr.ctn_id = ctn.CTN_ID;
|
|
|
|
|
cntr.ctnall = ctn.CTNALL;
|
|
|
|
|
cntr.cntrno = ctn.CNTRNO;
|
|
|
|
|
cntr.sealno = ctn.SEALNO;
|
|
|
|
|
cntr.chengZhongFangShi = ctn.WEIGHTYPE;
|
|
|
|
|
cntr.kgs = ctn.KGS;
|
|
|
|
|
cntr.pizhong = ctn.TAREWEIGHT;
|
|
|
|
|
cntr.chengZhongZhongLiang = ctn.KGS + ctn.TAREWEIGHT;
|
|
|
|
|
//cntr.yard = ctn.YARD;
|
|
|
|
|
cntr.yard = BasicDataRefDAL.GetCustEdiCodeByName2(ctn.YARD, "DJY");
|
|
|
|
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(ctn.WEIGHDATE))
|
|
|
|
|
cntr.chengZhongShiJian = ctn.WEIGHDATE.Replace("T"," ");
|
|
|
|
|
cntrlist.Add(cntr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
DsVgm.ctnList = cntrlist;
|
|
|
|
|
|
|
|
|
|
DsVgm.sendType = Convert.ToInt32(headData.SENDTYPE);
|
|
|
|
|
DsVgm.sendCarr = headData.ISCARRIER;
|
|
|
|
|
DsVgm.sendYGT = headData.ISYGT;
|
|
|
|
|
|
|
|
|
|
return DsVgm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public List<op_seae_vgm_history_md> GetVgmHistoryList(string BSNO)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new List<op_seae_vgm_history_md>();
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
result = cdc.op_seae_vgm_history
|
|
|
|
|
.Where(x => x.BSNO == BSNO)
|
|
|
|
|
.OrderByDescending(o=>o.SENDTIME).ToList();
|
|
|
|
|
|
|
|
|
|
if (result != null && result.Count > 0) {
|
|
|
|
|
var useridlist= result.Select(x => x.SENDERUSER).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
var userlist = cdc.VW_user.Where(x => useridlist.Contains(x.USERID)).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var item in result) {
|
|
|
|
|
item.SENDERNAME = userlist.FirstOrDefault(x => x.USERID == item.SENDERUSER).SHOWNAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
static public List<op_seae_vgm_state_md> GetStatusList(string BSNO,string type)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new List<op_seae_vgm_state_md>();
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
result = cdc.op_seae_vgm_state
|
|
|
|
|
.Where(x => x.mfno==BSNO&& x.Type==type)
|
|
|
|
|
.OrderByDescending(o => o.statustime).ToList();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 发送vgm至大简云
|
|
|
|
|
public static DBResult SendDjyVgm(MsOpVgmSend headData, List<MsOpVgmCtn> bodyList, string SendType = "")
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
result.OK();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var DsVgmUrl = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024URL'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
var headers = new NameValueCollection();
|
|
|
|
|
|
|
|
|
|
var key= MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_Key'").PARAMVALUE;
|
|
|
|
|
var secret = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_Secret'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
headers["USER_KEY"] = key;
|
|
|
|
|
headers["USER_SECRET"] = secret;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var OpSeaehead = MsOpSeaeDAL.MsOpSeaeDAL.GetData("BSNO='" + headData.BSNO + "'");
|
|
|
|
|
|
|
|
|
|
headData.MBLNO = OpSeaehead.MBLNO;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(SendType)) {
|
|
|
|
|
//临时性修改 不记录
|
|
|
|
|
headData.SENDTYPE = SendType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sendinfo = CreateDjyVgm(headData, bodyList, OpSeaehead);
|
|
|
|
|
|
|
|
|
|
BasicDataRefDAL.SaveLog(JsonConvert.Serialize(DsVgmUrl) + "////" + key +"////"+ secret + "////"+JsonConvert.Serialize(sendinfo), "", "DJYVGM2024", "发送");
|
|
|
|
|
var rtn = WebRequestHelper.DoPost_JSON_Header(DsVgmUrl, JsonConvert.Serialize(sendinfo), 10000,headers);
|
|
|
|
|
BasicDataRefDAL.SaveLog(rtn, "", "DJYVGM2024", "返回");
|
|
|
|
|
|
|
|
|
|
var _r = JsonConvert.Deserialize<djyvgmresult>(rtn);
|
|
|
|
|
|
|
|
|
|
if (_r.statusCode == 200)
|
|
|
|
|
{
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var updrec = cdc.op_seae_vgm_send.FirstOrDefault(x => x.BSNO == OpSeaehead.BSNO);
|
|
|
|
|
updrec.MFNO = _r.data.MFNO;
|
|
|
|
|
updrec.LINKURL = _r.data.LINKURL;
|
|
|
|
|
updrec.VGMSTATUS = _r.data.sendstatus;
|
|
|
|
|
cdc.op_seae_vgm_send.AddOrUpdate(updrec);
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
result.OK("上传成功",updrec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = _r.errors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 从大简云获取VGM链接
|
|
|
|
|
|
|
|
|
|
public class getlinkparam {
|
|
|
|
|
public string mfno { get; set; }
|
|
|
|
|
public bool sendCarr { get; set; } = false;
|
|
|
|
|
public bool sendYGT { get; set; } = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult GetDjyVgmLink(getlinkparam sendparam)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
result.OK();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var _head = cdc.op_seae_vgm_send.Where(p => p.BSNO == sendparam.mfno).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
//var head = MsOpVgmSendDAL.GetData("BSNO='" + sendparam.mfno + "'");
|
|
|
|
|
|
|
|
|
|
var DsVgmUrl = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024GetUrl'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
var headers = new NameValueCollection();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var key = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Key'").PARAMVALUE;
|
|
|
|
|
var secret = MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Secret'").PARAMVALUE;
|
|
|
|
|
|
|
|
|
|
//测试数据
|
|
|
|
|
//sendparam.mfno = "585399286181957";
|
|
|
|
|
|
|
|
|
|
headers["USER_KEY"] = key;// MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Key'").PARAMVALUE;
|
|
|
|
|
headers["USER_SECRET"] = secret;// MsSysParamSetDAL.GetData("PARAMNAME='DJYVGM2024_GetUrl_Secret'").PARAMVALUE;
|
|
|
|
|
var sendstr= JsonConvert.Serialize(sendparam);
|
|
|
|
|
|
|
|
|
|
var dic = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "mfno", sendparam.mfno },
|
|
|
|
|
{ "sendCarr", sendparam.sendCarr.ToString().ToLower() },
|
|
|
|
|
{ "sendYGT", sendparam.sendYGT.ToString().ToLower() }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BasicDataRefDAL.SaveLog(JsonConvert.Serialize(DsVgmUrl) + "////" + key +"//"+ secret + "////" + JsonConvert.Serialize(sendstr), "", "DJYVGM2024GetUrl", "发送");
|
|
|
|
|
var rtn = WebRequestHelper.DoGet_Param_Header(DsVgmUrl, dic, 10000, headers);
|
|
|
|
|
BasicDataRefDAL.SaveLog(rtn, "", "DJYVGM2024GetUrl", "返回");
|
|
|
|
|
|
|
|
|
|
获取vgm链接Result rp = JsonConvert.Deserialize<获取vgm链接Result>(rtn);
|
|
|
|
|
if (rp.statusCode == 200)
|
|
|
|
|
{
|
|
|
|
|
var _str = rp.data;
|
|
|
|
|
_head.LINKURL = BasicDataRefDAL.Unicode2String(_str);
|
|
|
|
|
|
|
|
|
|
_head.ISCARRIER = sendparam.sendCarr;
|
|
|
|
|
_head.ISYGT = sendparam.sendYGT;
|
|
|
|
|
|
|
|
|
|
cdc.op_seae_vgm_send.AddOrUpdate(_head);
|
|
|
|
|
cdc.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
result.OK("获取成功");
|
|
|
|
|
|
|
|
|
|
result.Data = _head.LINKURL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
result.SetErrorInfo(BasicDataRefDAL.Unicode2String(rp.errors));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 判断编码是否有重复
|
|
|
|
|
static public int GetRdCount(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" Count(BSNO) AS CT ");
|
|
|
|
|
strSql.Append(" from op_seae_pre ");
|
|
|
|
|
if (strCondition.Trim() != String.Empty)
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
var ct=0;
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ct = Convert.ToInt16(reader["CT"]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return ct;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Rang权限范围
|
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT");
|
|
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID");
|
|
|
|
|
strSql.Append(" from VW_User_Authority");
|
|
|
|
|
strSql.Append(" where [NAME]='modSaleRptList' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
|
|
string operaterange = "4";
|
|
|
|
|
string AUTHORITYID = "";
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (visiblerange == "4")
|
|
|
|
|
{
|
|
|
|
|
str = " SALE='" + username + "'";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "3")
|
|
|
|
|
{
|
|
|
|
|
str = " SALE='" + username + "'";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "2")
|
|
|
|
|
{
|
|
|
|
|
var rangeDa = new RangeDA();
|
|
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
|
|
str = " SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "5")
|
|
|
|
|
{
|
|
|
|
|
if (tb == "index")
|
|
|
|
|
{
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
|
|
{
|
|
|
|
|
str = "";
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
if (str == "")
|
|
|
|
|
{
|
|
|
|
|
str = " (SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + Convert.ToString(reader["COMPANYID"]) + "') ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = str + " or SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + Convert.ToString(reader["COMPANYID"]) + "')";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
str = str + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "6")
|
|
|
|
|
{
|
|
|
|
|
if (tb == "index")
|
|
|
|
|
{
|
|
|
|
|
var opstr = "";
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
|
|
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opstr == "")
|
|
|
|
|
{
|
|
|
|
|
opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opstr != "") opstr = opstr + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (opstr == "") opstr = "('" + username + "')";
|
|
|
|
|
str = " (OP in " + opstr + " )";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " (UPPER(op_other.Corpid)='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (visiblerange == "0")
|
|
|
|
|
{
|
|
|
|
|
str = " 1=1 ";
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|