1611 lines
68 KiB
C#
1611 lines
68 KiB
C#
using Google.Protobuf.WellKnownTypes;
|
|
using Models;
|
|
using Models.ModelGoods;
|
|
using Models.ModelItems;
|
|
using Models.ModelT;
|
|
using MySqlX.XDevAPI.Common;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using Services.Manager;
|
|
using Services.Tool;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlTypes;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Reflection.Emit;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Caching;
|
|
|
|
namespace Services.Api
|
|
{
|
|
public class OTApi
|
|
{
|
|
/// <summary>
|
|
/// 验证登录
|
|
/// </summary>
|
|
/// <param name="keyword">用户名</param>
|
|
/// <param name="password">密码</param>
|
|
/// <param name="token">是否返回token</param>
|
|
/// <returns></returns>
|
|
private static ReturnResult<TBL_UTS_Manage_User> GetLogo(string keyword, string password, string openid)
|
|
{
|
|
var res = new ReturnResult<TBL_UTS_Manage_User>();
|
|
try
|
|
{
|
|
|
|
TBL_UTS_Manage_User user = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == keyword);
|
|
if (user == null)
|
|
{
|
|
res.Status = 25;
|
|
res.Message = "账号不存在~";
|
|
Logs.WriteLog(res.Message);
|
|
return res;
|
|
}
|
|
if (user.PlaintextPwd != password)
|
|
{
|
|
res.Status = 50;
|
|
res.Message = "密码不正确~";
|
|
Logs.WriteLog(res.Message);
|
|
return res;
|
|
}
|
|
if (user.WeiXin != openid)
|
|
{
|
|
res.Data = null;
|
|
res.Status = 200; Logs.WriteLog(res.Message);
|
|
return res;
|
|
}
|
|
user.Password = null;
|
|
|
|
if (user.IsValid == 0)
|
|
{
|
|
res.Status = 300;
|
|
res.Message = "用户号码没有激活";
|
|
return res;
|
|
}
|
|
res.Data = user;
|
|
res.Status = 200;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
res.Status = 500;
|
|
res.Data = null;
|
|
res.Message = ex.Message;
|
|
Logs.WriteLog("验证登录出问题了:" + ex);
|
|
}
|
|
return res;
|
|
}
|
|
/// <summary>
|
|
/// 微信小程序 密码账号登录
|
|
/// </summary>
|
|
/// <param name="keyword">用户名</param>
|
|
/// <param name="password">密码</param>
|
|
/// <param name="appid">appid</param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> Wxlog(string keyword, string password, int appid, TBL_UTS_Manage_User userInfo = null, string openid = "", bool islong = false)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
var result = new ReturnResult<TBL_UTS_Manage_User>();
|
|
if (userInfo == null)
|
|
{
|
|
result = OTApi.GetLogo(keyword, password, openid);
|
|
}
|
|
else
|
|
{
|
|
result.Status = 200;
|
|
result.Data = userInfo;
|
|
Logs.WriteTimingPlanLog("用户名:" + keyword + "密码:" + password + "登录成功:" + result.Data);
|
|
|
|
}
|
|
//判断登录
|
|
if (result.Status != 200)
|
|
{
|
|
resdata.Message = result.Message;
|
|
resdata.Status = result.Status;
|
|
Logs.WriteTimingPlanLog("用户名:" + keyword + "密码:" + password + "登录失败,信息:" + resdata.Message);
|
|
|
|
return resdata;
|
|
}
|
|
float day = 1;
|
|
if (islong)
|
|
{
|
|
day = 30;
|
|
}
|
|
Dictionary<string, object> aa = new Dictionary<string, object>() { { "data", result.Data } };
|
|
resdata.Data = new
|
|
{
|
|
userinfo = result.Data,
|
|
token = TokenHelper.GetToken(aa, day)
|
|
};
|
|
resdata.Status = 200;
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 外箱码信息查询
|
|
/// </summary>
|
|
/// <param name="goodid"></param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> WxBoxnumber(string goodid, string dingdan)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
var result = new ReturnResult<uts_zongqing_tbl_importinfo>();
|
|
List<uts_zongqing_tbl_importinfo> goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_importinfo>().Where(x => x.OutBoxCode == goodid).ToList();
|
|
if (goods.Count != 0)
|
|
{
|
|
List<uts_zongqing_tbl_importinfo> goodsw = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_importinfo>().Where(x => x.ShippingCode == dingdan).ToList();
|
|
int nummm = goodsw.Count();
|
|
uts_zongqing_tbl_shipping goodshulian = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.ShippingCode == dingdan).First();
|
|
if (nummm == goodshulian.QTY)
|
|
{
|
|
var resulta = SqlSugarGoodsBase.Db.Updateable<uts_zongqing_tbl_shipping>().SetColumns(it => new uts_zongqing_tbl_shipping() { Status = 3 })
|
|
.Where(it => it.ShippingCode == goodshulian.ShippingCode).ExecuteCommand();
|
|
resdata.Status = 400;
|
|
resdata.Message = "数量已经预订单匹配上了,可以休息一下";
|
|
Logs.WriteLog(resdata.Message);
|
|
resdata.Data = new
|
|
{
|
|
userinfo = "",
|
|
Project = ""
|
|
};
|
|
}
|
|
|
|
else
|
|
{
|
|
TBL_Project goodss = new TBL_Project();
|
|
foreach (var item in goods)
|
|
{
|
|
goodss = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
resdata.PID = item.ProjectID;
|
|
}
|
|
//彩和数量
|
|
resdata.nums = goods.Count();
|
|
|
|
//机型
|
|
resdata.Name = goodss.ProjectName;
|
|
resdata.Data = new
|
|
{
|
|
userinfo = goods,
|
|
Project = goodss
|
|
};
|
|
resdata.Status = 200;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
resdata.Status = 300;
|
|
resdata.Message = "您扫的码没有匹配到相应的数据请重新扫码";
|
|
resdata.nums = 0;
|
|
resdata.Data = new
|
|
{
|
|
userinfo = "",
|
|
Project = ""
|
|
};
|
|
}
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 订单编号和状态查询
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> GetdingdanbyID1(string ShippingCode, int Status, int ProjectListID)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
List<uts_zongqing_tbl_shipping> goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{
|
|
if (item.Status == 1)
|
|
{
|
|
//未装箱数量
|
|
resdata.wzx++;
|
|
}
|
|
else if (item.Status == 2)
|
|
{
|
|
//装箱中数量
|
|
resdata.zxz++;
|
|
}
|
|
else
|
|
{
|
|
//已完成数量
|
|
resdata.shuliabn++;
|
|
}
|
|
resdata.quabu++;
|
|
}
|
|
|
|
uts_zongqing_tbl_shipping uts_Zongqing_Tbl = new uts_zongqing_tbl_shipping();
|
|
List<TBL_Project> goodss = new List<TBL_Project>();
|
|
int outnum = 0;
|
|
|
|
if (ShippingCode != "" && Status != 0 && ProjectListID != 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode) && x.Status == Status && x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{
|
|
//需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode == "" && Status != 0 && ProjectListID != 0)
|
|
{
|
|
|
|
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.Status == Status && x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{
|
|
//需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode != "" && Status == 0 && ProjectListID != 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode) && x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode != "" && Status != 0 && ProjectListID == 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode) && x.Status == Status).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode != "" && Status == 0 && ProjectListID == 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode)).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode == "" && Status != 0 && ProjectListID == 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.Status == Status).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode == "" && Status == 0 && ProjectListID != 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
List<uts_zongqing_tbl_importinfo> coos = new List<uts_zongqing_tbl_importinfo>();
|
|
|
|
Dictionary<String, List<uts_zongqing_tbl_importinfo>> outboxList = new Dictionary<string, List<uts_zongqing_tbl_importinfo>>();
|
|
|
|
if (goods.Count == 1)
|
|
{
|
|
coos = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_importinfo>().Where(x => x.ShippingCode == ShippingCode).OrderByDescending(x => x.ShippingDateTime).ToList();
|
|
int ProjectID = 0;
|
|
if (coos.Count() > 0)
|
|
{
|
|
foreach (uts_zongqing_tbl_importinfo item in coos)
|
|
{
|
|
if (outboxList.ContainsKey(item.OutBoxCode))
|
|
outboxList[item.OutBoxCode].Add(item);
|
|
else
|
|
{
|
|
List<uts_zongqing_tbl_importinfo> tmpList = new List<uts_zongqing_tbl_importinfo>();
|
|
outboxList[item.OutBoxCode] = tmpList;
|
|
tmpList.Add(item);
|
|
|
|
}
|
|
ProjectID = item.ProjectID;
|
|
TBL_Project g = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == ProjectID);
|
|
goodss.Add(g);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in goods)
|
|
{
|
|
ProjectID = item.ProjectID;
|
|
TBL_Project g = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == ProjectID);
|
|
goodss.Add(g);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//过滤Shipping机型
|
|
List<TBL_Project> ghas = SqlBase.Db.Queryable<TBL_Project>().Where(x => x.ProjectName != "Shipping").ToList();
|
|
List<ProbjectType> asg = new List<ProbjectType>();
|
|
foreach (var item in ghas)
|
|
{
|
|
ProbjectType tBL_Project = new ProbjectType();
|
|
tBL_Project.text = item.ProjectName;
|
|
tBL_Project.value = item.ID;
|
|
asg.Add(tBL_Project);
|
|
}
|
|
int namrt = outnum;
|
|
resdata.Data = new
|
|
{
|
|
userinfo = goods,
|
|
SC = outboxList.ToArray(),
|
|
ProjectList = goodss,
|
|
TBL_Projectytpe = asg
|
|
};
|
|
resdata.Status = 200;
|
|
resdata.bandingshulian = coos.Count();
|
|
return resdata;
|
|
}
|
|
public static ReturnResult<dynamic> GetdingdanbyID2(string ShippingCode, int Status, int ProjectListID)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
List<uts_johao_tbl_shipping> goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{
|
|
if (item.Status == 1)
|
|
{
|
|
//未装箱数量
|
|
resdata.wzx++;
|
|
}
|
|
else if (item.Status == 2)
|
|
{
|
|
//装箱中数量
|
|
resdata.zxz++;
|
|
}
|
|
else
|
|
{
|
|
//已完成数量
|
|
resdata.shuliabn++;
|
|
}
|
|
resdata.quabu++;
|
|
}
|
|
|
|
uts_johao_tbl_shipping uts_Zongqing_Tbl = new uts_johao_tbl_shipping();
|
|
List<TBL_Project> goodss = new List<TBL_Project>();
|
|
int outnum = 0;
|
|
|
|
if (ShippingCode != "" && Status != 0 && ProjectListID != 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode) && x.Status == Status && x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{
|
|
//需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode == "" && Status != 0 && ProjectListID != 0)
|
|
{
|
|
|
|
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.Status == Status && x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{
|
|
//需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode != "" && Status == 0 && ProjectListID != 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode) && x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode != "" && Status != 0 && ProjectListID == 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode) && x.Status == Status).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode != "" && Status == 0 && ProjectListID == 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.ShippingCode.Contains(ShippingCode)).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode == "" && Status != 0 && ProjectListID == 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.Status == Status).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else if (ShippingCode == "" && Status == 0 && ProjectListID != 0)
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.ProjectID == ProjectListID).OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().OrderByDescending(x => x.CreateDateTime).ToList();
|
|
foreach (var item in goods)
|
|
{ //需要修改
|
|
if (item.ProjectID == 0)
|
|
{
|
|
item.ProjectID = 3;
|
|
}
|
|
//状态
|
|
resdata.nums = item.Status;
|
|
resdata.PID = item.ProjectID;
|
|
TBL_Project goodsa = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == item.ProjectID);
|
|
goodss.Add(goodsa);
|
|
}
|
|
}
|
|
List<uts_johao_tbl_importinfo> coos = new List<uts_johao_tbl_importinfo>();
|
|
|
|
Dictionary<String, List<uts_johao_tbl_importinfo>> outboxList = new Dictionary<string, List<uts_johao_tbl_importinfo>>();
|
|
|
|
if (goods.Count == 1)
|
|
{
|
|
coos = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_importinfo>().Where(x => x.ShippingCode == ShippingCode).OrderByDescending(x => x.ShippingDateTime).ToList();
|
|
int ProjectID = 0;
|
|
if (coos.Count() > 0)
|
|
{
|
|
foreach (uts_johao_tbl_importinfo item in coos)
|
|
{
|
|
if (outboxList.ContainsKey(item.OutBoxCode))
|
|
outboxList[item.OutBoxCode].Add(item);
|
|
else
|
|
{
|
|
List<uts_johao_tbl_importinfo> tmpList = new List<uts_johao_tbl_importinfo>();
|
|
outboxList[item.OutBoxCode] = tmpList;
|
|
tmpList.Add(item);
|
|
|
|
}
|
|
ProjectID = item.ProjectID;
|
|
TBL_Project g = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == ProjectID);
|
|
goodss.Add(g);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in goods)
|
|
{
|
|
ProjectID = item.ProjectID;
|
|
TBL_Project g = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == ProjectID);
|
|
goodss.Add(g);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//过滤Shipping机型
|
|
List<TBL_Project> ghas = SqljohaoBase.Db.Queryable<TBL_Project>().Where(x => x.ProjectName != "Shipping").ToList();
|
|
List<ProbjectType> asg = new List<ProbjectType>();
|
|
foreach (var item in ghas)
|
|
{
|
|
ProbjectType tBL_Project = new ProbjectType();
|
|
tBL_Project.text = item.ProjectName;
|
|
tBL_Project.value = item.ID;
|
|
asg.Add(tBL_Project);
|
|
}
|
|
int namrt = outnum;
|
|
resdata.Data = new
|
|
{
|
|
userinfo = goods,
|
|
SC = outboxList.ToArray(),
|
|
ProjectList = goodss,
|
|
TBL_Projectytpe = asg
|
|
};
|
|
|
|
|
|
|
|
resdata.Status = 200;
|
|
resdata.bandingshulian = coos.Count();
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 查询彩盒码信息
|
|
/// </summary>
|
|
/// <param name="CHID">彩盒码</param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> CHBYTs(string CHID)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
uts_johao_tbl_importinfo goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_importinfo>().First(x => x.ColorBox_BarCode == CHID);
|
|
List<TBL_StationList> tBL = new List<TBL_StationList>();
|
|
if (CHID != null)
|
|
{
|
|
tBL = SqlSugarByT.Db.Queryable<TBL_StationList>().Where(x => x.ProjectID == goods.ProjectID).ToList();
|
|
|
|
}
|
|
|
|
resdata.Data = new
|
|
{
|
|
userinfo = tBL
|
|
};
|
|
resdata.Status = 200;
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 绑定
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <param name="outid"></param>
|
|
/// <param name="UserName"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi Add2(string ShippingCode, string outid, string UserName)
|
|
{
|
|
jsonapi retval = new jsonapi();
|
|
try
|
|
{
|
|
retval = BindOutboxToShipping(outid, ShippingCode, UserName);
|
|
retval.ProjectName = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == retval.ProjectID).ProjectName;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retval.Message = "绑定失败";
|
|
Logs.WriteLog("绑定失败:" + ex);
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
public static jsonapi Add3(string ShippingCode, string outid, string UserName)
|
|
{
|
|
jsonapi retval = new jsonapi();
|
|
try
|
|
{
|
|
retval = BindOutboxToShippingjh(outid, ShippingCode, UserName);
|
|
retval.ProjectName = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == retval.ProjectID).ProjectName;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retval.Message = "绑定失败";
|
|
Logs.WriteLog("绑定失败:" + ex);
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 解绑
|
|
/// </summary>
|
|
/// <param name="ShippingCode">订单编号</param>
|
|
/// <param name="OutBoxCodeList">外箱码集合</param>
|
|
/// <returns></returns>
|
|
public static jsonapi Edit(string ShippingCode, string OutBoxCodeList = null, string UserName = "")
|
|
{
|
|
jsonapi retval = new jsonapi();
|
|
try
|
|
{
|
|
retval = UnbindOutboxToShipping(OutBoxCodeList, UserName);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retval.Message = "解绑失败";
|
|
Logs.WriteLog("解绑失败:" + ex);
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
public static jsonapi Edit1(string ShippingCode, string OutBoxCodeList = null, string UserName = "")
|
|
{
|
|
jsonapi retval = new jsonapi();
|
|
try
|
|
{
|
|
retval = UnbindOutboxToShippingjh(OutBoxCodeList, UserName);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retval.Message = "解绑失败";
|
|
Logs.WriteLog("解绑失败:" + ex);
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
/// <summary>
|
|
/// 获取外箱码信息
|
|
/// </summary>
|
|
/// <param name="outCode">外箱码</param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> GetoutIDbyIDs(string outCode)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
|
|
var result = new ReturnResult<uts_zongqing_tbl_importinfo>();
|
|
List<uts_zongqing_tbl_importinfo> goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_importinfo>().Where(x => x.OutBoxCode == outCode).ToList();
|
|
string pname = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == goods[0].ProjectID).ProjectName;
|
|
resdata.ProjectName = pname;
|
|
resdata.nums = goods.Count;
|
|
resdata.Data = goods;
|
|
resdata.Name = outCode;
|
|
resdata.Status = 200;
|
|
return resdata;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 把用户微信openid写入数据库
|
|
/// </summary>
|
|
/// <param name="Uid">用户名</param>
|
|
/// <param name="openid">openid</param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> AddTelAndopenId(string Uid = "", string openid = "")
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
List<TBL_UTS_Manage_User> user = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().Where(x => x.WeiXin == openid).ToList();
|
|
if (user.Count == 0)
|
|
{
|
|
TBL_UTS_Manage_User users = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == Uid);
|
|
if (users.WeiXin == null || users.WeiXin == "")
|
|
{
|
|
var result = SqlSugarBase.Db.Updateable<TBL_UTS_Manage_User>().SetColumns(it => new TBL_UTS_Manage_User() { WeiXin = openid })
|
|
.Where(it => it.ID == users.ID).ExecuteCommand();
|
|
//请求成功
|
|
resdata.Status = 200;
|
|
}
|
|
else
|
|
{
|
|
//这个账号被绑定了
|
|
resdata.Status = 300;
|
|
Logs.WriteLog("这个账号被绑定了");
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//你的微信号码已经绑定了,请换一个微信来注册
|
|
resdata.Status = 400;
|
|
Logs.WriteLog("你的微信号码已经绑定了,请换一个微信来注册");
|
|
}
|
|
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 结单
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> SettleTheBills(string ShippingCode = "", string UserName = "")
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
|
|
List<uts_zongqing_tbl_shipping> goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().ToList();
|
|
|
|
try
|
|
{
|
|
jsonapi UnbindOutboxToShippings = CompleteShipping(ShippingCode, UserName);
|
|
if (UnbindOutboxToShippings.Status == false)
|
|
{
|
|
resdata.Status = 212;
|
|
resdata.Message = UnbindOutboxToShippings.Message;
|
|
Logs.WriteLog(resdata.Message);
|
|
return resdata;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
resdata.Message = "结单api错误";
|
|
Logs.WriteLog(resdata.Message + ":" + ex);
|
|
}
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().Where(x => x.ShippingCode == ShippingCode).ToList();
|
|
int ProjectID = goods[0].ProjectID;
|
|
List<TBL_Project> tBLp = SqlBase.Db.Queryable<TBL_Project>().Where(x => x.ID == ProjectID).ToList();
|
|
resdata.Data = new
|
|
{
|
|
username = goods,
|
|
pname = tBLp
|
|
};
|
|
resdata.Status = 200;
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 结单jh
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <param name="UserName"></param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> SettleTheBills1(string ShippingCode = "", string UserName = "")
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
|
|
List<uts_johao_tbl_shipping> goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().ToList();
|
|
|
|
try
|
|
{
|
|
|
|
jsonapi UnbindOutboxToShippings = CompleteShippingjh(ShippingCode, UserName);
|
|
if (UnbindOutboxToShippings.Status == false)
|
|
{
|
|
resdata.Status = 212;
|
|
resdata.Message = UnbindOutboxToShippings.Message;
|
|
Logs.WriteLog(resdata.Message);
|
|
return resdata;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
resdata.Message = "结单api错误";
|
|
Logs.WriteLog(resdata.Message + ":" + ex);
|
|
}
|
|
goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().Where(x => x.ShippingCode == ShippingCode).ToList();
|
|
int ProjectID = goods[0].ProjectID;
|
|
List<TBL_Project> tBLp = SqljohaoBase.Db.Queryable<TBL_Project>().Where(x => x.ID == ProjectID).ToList();
|
|
resdata.Data = new
|
|
{
|
|
username = goods,
|
|
pname = tBLp
|
|
};
|
|
resdata.Status = 200;
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 查看日志
|
|
/// </summary>
|
|
/// <param name="starttime">开始时间</param>
|
|
/// <param name="endtime">结束时间</param>
|
|
/// <param name="ShippingCode">订单编号</param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> Viewlog(string starttime, string endtime, string ShippingCode, string Outcode, int czuo, int jixing)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
List<TBL_Project> g = SqlBase.Db.Queryable<TBL_Project>().Where(x => x.ProjectName != "Shipping").ToList();
|
|
|
|
Nullable<DateTime> startstime = null;
|
|
Nullable<DateTime> endstime = null;
|
|
if (!string.IsNullOrEmpty(starttime))
|
|
{
|
|
startstime = Convert.ToDateTime(starttime);
|
|
endstime = Convert.ToDateTime(endtime);
|
|
}
|
|
List<uts_bindhistoryinfo_log> bindhistoryinfo_log = SqlSugarGoodsBase.Db.Queryable<uts_bindhistoryinfo_log>()
|
|
.Where(x => x.operateType == 4 || x.operateType == 5 || x.operateType == 6 || x.operateType == 7).GroupBy(x => x.importinfoID)
|
|
.Select(it => new uts_bindhistoryinfo_log
|
|
{
|
|
ID = SqlFunc.AggregateMax(it.ID),
|
|
importinfoID = SqlFunc.AggregateMax(it.importinfoID),
|
|
operateTime = SqlFunc.AggregateMax(it.operateTime),
|
|
operateType = SqlFunc.AggregateMax(it.operateType),
|
|
Result = SqlFunc.AggregateMax(it.Result),
|
|
ProjectID = SqlFunc.AggregateMax(it.ProjectID),
|
|
OutBoxCode = SqlFunc.AggregateMax(it.OutBoxCode),
|
|
Barcode = SqlFunc.AggregateMax(it.Barcode),
|
|
ColorBox_BarCode = SqlFunc.AggregateMax(it.ColorBox_BarCode),
|
|
ShippingCode = SqlFunc.AggregateMax(it.ShippingCode),
|
|
Remark = SqlFunc.AggregateMax(it.Remark),
|
|
ShippingOperator = SqlFunc.AggregateMax(it.ShippingOperator),
|
|
})
|
|
.OrderByDescending(x => x.operateTime).ToPageList(1, 500)
|
|
.ToList();
|
|
|
|
foreach (var itrm in bindhistoryinfo_log)
|
|
{
|
|
List<TBL_Project> listsm = g.Where(x => x.ID == itrm.ProjectID).ToList();
|
|
if (listsm.Count > 0)
|
|
{
|
|
itrm.ProjectName = listsm[0].ProjectName;
|
|
}
|
|
}
|
|
if (startstime != null && endstime != null)
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.operateTime >= startstime && x.operateTime <= endstime).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty(ShippingCode))
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.ShippingCode.Contains(ShippingCode)).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty(Outcode))
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.OutBoxCode.Contains(Outcode)).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (czuo != 3)
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.operateType == czuo).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (jixing != 0)
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.ProjectID == jixing).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
|
|
|
|
resdata.Status = 200;
|
|
resdata.Data = new
|
|
{
|
|
bindhistoryinfo = bindhistoryinfo_log,
|
|
TBL_Project = g
|
|
};
|
|
return resdata;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ReturnResult<dynamic> Viewlog1(string starttime, string endtime, string ShippingCode, string Outcode, int czuo, int jixing)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
List<TBL_Project> g = SqljohaoBase.Db.Queryable<TBL_Project>().ToList();
|
|
Nullable<DateTime> startstime = null;
|
|
Nullable<DateTime> endstime = null;
|
|
if (!string.IsNullOrEmpty(starttime))
|
|
{
|
|
startstime = Convert.ToDateTime(starttime);
|
|
endstime = Convert.ToDateTime(endtime);
|
|
}
|
|
List<uts_bindhistoryinfo_log> bindhistoryinfo_log = SqlSugarGoodsBase.Db.Queryable<uts_bindhistoryinfo_log>()
|
|
|
|
.Where(x => x.operateType == 4 || x.operateType == 5 || x.operateType == 6 || x.operateType == 7).GroupBy(x => x.importinfoID)
|
|
.Select(it => new uts_bindhistoryinfo_log
|
|
{
|
|
ID = SqlFunc.AggregateMax(it.ID),
|
|
importinfoID = SqlFunc.AggregateMax(it.importinfoID),
|
|
operateTime = SqlFunc.AggregateMax(it.operateTime),
|
|
operateType = SqlFunc.AggregateMax(it.operateType),
|
|
Result = SqlFunc.AggregateMax(it.Result),
|
|
ProjectID = SqlFunc.AggregateMax(it.ProjectID),
|
|
OutBoxCode = SqlFunc.AggregateMax(it.OutBoxCode),
|
|
Barcode = SqlFunc.AggregateMax(it.Barcode),
|
|
ColorBox_BarCode = SqlFunc.AggregateMax(it.ColorBox_BarCode),
|
|
ShippingCode = SqlFunc.AggregateMax(it.ShippingCode),
|
|
Remark = SqlFunc.AggregateMax(it.Remark),
|
|
ShippingOperator = SqlFunc.AggregateMax(it.ShippingOperator),
|
|
})
|
|
.OrderByDescending(x => x.operateTime).ToPageList(1, 500)
|
|
.ToList();
|
|
|
|
foreach (var itrm in bindhistoryinfo_log)
|
|
{
|
|
List<TBL_Project> listsm = g.Where(x => x.ID == itrm.ProjectID).ToList();
|
|
if (listsm.Count > 0)
|
|
{
|
|
itrm.ProjectName = listsm[0].ProjectName;
|
|
}
|
|
}
|
|
if (startstime != null && endstime != null)
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.operateTime >= startstime && x.operateTime <= endstime).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty(ShippingCode))
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.ShippingCode.Contains(ShippingCode)).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty(Outcode))
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.OutBoxCode.Contains(Outcode)).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (czuo != 3)
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.operateType == czuo).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
if (jixing != 0)
|
|
{
|
|
bindhistoryinfo_log = bindhistoryinfo_log.Where(x => x.ProjectID == jixing).OrderByDescending(x => x.operateTime).ToList();
|
|
}
|
|
|
|
|
|
|
|
resdata.Status = 200;
|
|
resdata.Data = new
|
|
{
|
|
bindhistoryinfo = bindhistoryinfo_log,
|
|
TBL_Project = g
|
|
};
|
|
return resdata;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// toenk登录
|
|
/// </summary>
|
|
/// <param name="token"></param>
|
|
/// <param name="appid"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public static ReturnResult<dynamic> WxlogToken(string token, int appid)
|
|
{
|
|
var chektoken = TokenHelper.CheckToken(token);
|
|
var resdata = new ReturnResult<dynamic>();
|
|
TBL_UTS_Manage_User userinfo = new TBL_UTS_Manage_User();
|
|
if (!string.IsNullOrEmpty(chektoken))
|
|
{
|
|
chektoken = chektoken.Replace("{{", "{").Replace("}}", "}");
|
|
userinfo = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(chektoken);
|
|
resdata = OTApi.Wxlog(userinfo.UserName, userinfo.PlaintextPwd, appid, userinfo, userinfo.WeiXin);
|
|
|
|
}
|
|
else
|
|
{
|
|
resdata.Status = 1024;
|
|
resdata.Data = null;
|
|
resdata.Message = "token过期~";
|
|
}
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 使用api接口绑定uts_zongqing
|
|
/// </summary>
|
|
/// <param name="OutBoxCode"></param>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi BindOutboxToShipping(string OutBoxCode, string ShippingCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/BindOutboxToShipping";
|
|
string url = " http://localhost:55151/CommonApi/BindOutboxToShipping";
|
|
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
past.OutBoxCode = OutBoxCode;
|
|
past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//string postData = "{Pwd:\"\",OutBoxCode:\"OutBoxCode\",ShippingCode:\"ShippingCode\",MO:\"zzz\",istest:1}";
|
|
//"{ ID: \"1\", NAME: \"Jim\", CREATETIME: \"1988-09-11\" }";
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
var shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 使用api接口绑定uts_johao
|
|
/// </summary>
|
|
/// <param name="OutBoxCode"></param>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi BindOutboxToShippingjh(string OutBoxCode, string ShippingCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/BindOutboxToShippingjh";
|
|
string url = " http://localhost:55151/CommonApi/BindOutboxToShippingjh";
|
|
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
past.OutBoxCode = OutBoxCode;
|
|
past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//string postData = "{Pwd:\"\",OutBoxCode:\"OutBoxCode\",ShippingCode:\"ShippingCode\",MO:\"zzz\",istest:1}";
|
|
//"{ ID: \"1\", NAME: \"Jim\", CREATETIME: \"1988-09-11\" }";
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
var shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
/// <summary>
|
|
/// 使用api解绑uts_zongqing
|
|
/// </summary>
|
|
/// <param name="OutBoxCode"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi UnbindOutboxToShipping(string OutBoxCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/UnbindOutboxToShipping";
|
|
string url = " http://localhost:55151/CommonApi/UnbindOutboxToShipping";
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
past.OutBoxCode = OutBoxCode;
|
|
//past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//string postData = "{Pwd:\"\",OutBoxCode:\"OutBoxCode\",ShippingCode:\"ShippingCode\",MO:\"zzz\",istest:1}";
|
|
//"{ ID: \"1\", NAME: \"Jim\", CREATETIME: \"1988-09-11\" }";
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
var shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
/// <summary>
|
|
/// 使用api解绑uts_johao
|
|
/// </summary>
|
|
/// <param name="OutBoxCode"></param>
|
|
/// <param name="UserName"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi UnbindOutboxToShippingjh(string OutBoxCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/UnbindOutboxToShippingjh";
|
|
string url = " http://localhost:55151/CommonApi/UnbindOutboxToShippingjh";
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
past.OutBoxCode = OutBoxCode;
|
|
//past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//string postData = "{Pwd:\"\",OutBoxCode:\"OutBoxCode\",ShippingCode:\"ShippingCode\",MO:\"zzz\",istest:1}";
|
|
//"{ ID: \"1\", NAME: \"Jim\", CREATETIME: \"1988-09-11\" }";
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
var shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
/// <summary>
|
|
/// 结单uts_zongqing
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi CompleteShipping(string ShippingCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/CompleteShipping";
|
|
string url = " http://localhost:55151/CommonApi/CompleteShipping";
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
//past.OutBoxCode = OutBoxCode;
|
|
past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
jsonapi shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
/// <summary>
|
|
/// 结单uts_johao
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <param name="UserName"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi CompleteShippingjh(string ShippingCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/CompleteShippingjh";
|
|
string url = " http://localhost:55151/CommonApi/CompleteShippingjh";
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
//past.OutBoxCode = OutBoxCode;
|
|
past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
jsonapi shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
/// <summary>
|
|
/// 已结单后有权限的人修改状态
|
|
/// </summary>
|
|
/// <param name="ShippingCodes"></param>
|
|
/// <param name="token"></param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> Eentstatus(string shippingCodes, string userName)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
try
|
|
{
|
|
jsonapi UnbindOutboxToShippings = UnCompleteShipping(shippingCodes, userName); ;
|
|
if (UnbindOutboxToShippings.Status == false)
|
|
{
|
|
resdata.Status = 212;
|
|
resdata.Message = UnbindOutboxToShippings.Message;
|
|
Logs.WriteLog(resdata.Message);
|
|
return resdata;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resdata.Message = "已结单后有权限的人修改状态api错误";
|
|
Logs.WriteLog(resdata.Message + ":" + ex);
|
|
}
|
|
resdata.Status = 200;
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 已结单后有权限的人修改状态jh
|
|
/// </summary>
|
|
/// <param name="ShippingCodes"></param>
|
|
/// <param name="token"></param>
|
|
/// <returns></returns>
|
|
public static ReturnResult<dynamic> Eentstatus1(string shippingCodes, string userName)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
try
|
|
{
|
|
jsonapi UnbindOutboxToShippings = UnCompleteShippingjh(shippingCodes, userName); ;
|
|
if (UnbindOutboxToShippings.Status == false)
|
|
{
|
|
resdata.Status = 212;
|
|
resdata.Message = UnbindOutboxToShippings.Message;
|
|
Logs.WriteLog(resdata.Message);
|
|
return resdata;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resdata.Message = "已结单后有权限的人修改状态api错误";
|
|
Logs.WriteLog(resdata.Message + ":" + ex);
|
|
}
|
|
resdata.Status = 200;
|
|
return resdata;
|
|
}
|
|
/// <summary>
|
|
/// 已结单后有权限的人修改状态uts_zongqing
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <param name="UserName"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi UnCompleteShipping(string ShippingCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/UnCompleteShipping";
|
|
string url = " http://localhost:55151/CommonApi/UnCompleteShipping";
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
//past.OutBoxCode = OutBoxCode;
|
|
past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
jsonapi shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
/// <summary>
|
|
/// 已结单后有权限的人修改状态uts_johao
|
|
/// </summary>
|
|
/// <param name="ShippingCode"></param>
|
|
/// <param name="UserName"></param>
|
|
/// <returns></returns>
|
|
public static jsonapi UnCompleteShippingjh(string ShippingCode, string UserName)
|
|
{
|
|
//请求路径
|
|
//string url = "http://uts-data.com/CommonApi/UnCompleteShippingjh";
|
|
string url = " http://localhost:55151/CommonApi/UnCompleteShippingjh";
|
|
//定义request并设置request的路径
|
|
WebRequest request = WebRequest.Create(url);
|
|
request.Method = "post";
|
|
BehindPast past = new BehindPast();
|
|
//past.OutBoxCode = OutBoxCode;
|
|
past.ShippingCode = ShippingCode;
|
|
past.Pwd = "actop00803";
|
|
past.MO = "";
|
|
past.Loader = UserName;
|
|
//初始化request参数
|
|
//设置参数的编码格式,解决中文乱码
|
|
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(past);
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
|
|
//设置request的MIME类型及内容长度
|
|
request.ContentType = "application/json";
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
//打开request字符流
|
|
Stream dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
|
|
//定义response为前面的request响应
|
|
WebResponse response = request.GetResponse();
|
|
|
|
//获取相应的状态代码
|
|
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
|
|
//定义response字符流
|
|
dataStream = response.GetResponseStream();
|
|
StreamReader reader = new StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();//读取所有
|
|
|
|
jsonapi shujiu = JsonConvert.DeserializeObject<jsonapi>(responseFromServer);
|
|
return shujiu;
|
|
}
|
|
/// <summary>
|
|
/// 根据订单号码查询订单信息
|
|
/// </summary>
|
|
/// <param name="shippingCode"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public static ReturnResult<dynamic> GetQrderInformationByShippingCode(string shippingCode)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
try
|
|
{
|
|
uts_zongqing_tbl_shipping goods = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_shipping>().First(x => x.ShippingCode == shippingCode);
|
|
TBL_Project tBLp = SqlBase.Db.Queryable<TBL_Project>().First(x => x.ID == goods.ProjectID);
|
|
|
|
List<uts_zongqing_tbl_importinfo> importinfo = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_importinfo>().Where(x => x.ShippingCode == shippingCode).ToList();
|
|
|
|
ShippingProject shippingProject = new ShippingProject();
|
|
shippingProject.ID = goods.ID;
|
|
shippingProject.ShippingCode = goods.ShippingCode;
|
|
shippingProject.Creator = goods.Creator;
|
|
shippingProject.CreateDateTime = goods.CreateDateTime;
|
|
shippingProject.StartDateTime = goods.StartDateTime;
|
|
shippingProject.EndDateTime = goods.EndDateTime;
|
|
shippingProject.Loader = goods.Loader;
|
|
shippingProject.Status = goods.Status;
|
|
shippingProject.ShippingType = goods.ShippingType;
|
|
shippingProject.Destination = goods.Destination;
|
|
shippingProject.Voucher = goods.Voucher;
|
|
shippingProject.Remark = goods.Remark;
|
|
shippingProject.ProjectID = goods.ProjectID;
|
|
shippingProject.QTY = goods.QTY;
|
|
shippingProject.MO = goods.MO;
|
|
shippingProject.Customer = goods.Customer;
|
|
shippingProject.ProjectName = tBLp.ProjectName;
|
|
shippingProject.ProductTypeID = tBLp.ProductTypeID;
|
|
shippingProject.bandingnum = importinfo.Count;
|
|
resdata.Data = new
|
|
{
|
|
shippingByProject = shippingProject,
|
|
};
|
|
resdata.Status = 200;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resdata.Status = 400;
|
|
resdata.Message = "结单api错误";
|
|
Logs.WriteLog(resdata.Message + ":" + ex);
|
|
}
|
|
return resdata;
|
|
}
|
|
public static ReturnResult<dynamic> GetQrderInformationByShippingCode1(string shippingCode)
|
|
{
|
|
var resdata = new ReturnResult<dynamic>();
|
|
try
|
|
{
|
|
uts_johao_tbl_shipping goods = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_shipping>().First(x => x.ShippingCode == shippingCode);
|
|
TBL_Project tBLp = SqljohaoBase.Db.Queryable<TBL_Project>().First(x => x.ID == goods.ProjectID);
|
|
|
|
List<uts_johao_tbl_importinfo> importinfo = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_importinfo>().Where(x => x.ShippingCode == shippingCode).ToList();
|
|
|
|
ShippingProject shippingProject = new ShippingProject();
|
|
shippingProject.ID = goods.ID;
|
|
shippingProject.ShippingCode = goods.ShippingCode;
|
|
shippingProject.Creator = goods.Creator;
|
|
shippingProject.CreateDateTime = goods.CreateDateTime;
|
|
shippingProject.StartDateTime = goods.StartDateTime;
|
|
shippingProject.EndDateTime = goods.EndDateTime;
|
|
shippingProject.Loader = goods.Loader;
|
|
shippingProject.Status = goods.Status;
|
|
shippingProject.ShippingType = goods.ShippingType;
|
|
shippingProject.Destination = goods.Destination;
|
|
shippingProject.Voucher = goods.Voucher;
|
|
shippingProject.Remark = goods.Remark;
|
|
shippingProject.ProjectID = goods.ProjectID;
|
|
shippingProject.QTY = goods.QTY;
|
|
shippingProject.MO = goods.MO;
|
|
shippingProject.Customer = goods.Customer;
|
|
shippingProject.ProjectName = tBLp.ProjectName;
|
|
shippingProject.ProductTypeID = tBLp.ProductTypeID;
|
|
shippingProject.bandingnum = importinfo.Count;
|
|
resdata.Data = new
|
|
{
|
|
shippingByProject = shippingProject,
|
|
};
|
|
resdata.Status = 200;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resdata.Status = 400;
|
|
resdata.Message = "结单api错误";
|
|
Logs.WriteLog(resdata.Message + ":" + ex);
|
|
}
|
|
return resdata;
|
|
}
|
|
|
|
}
|
|
} |