using DBUtility;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using SQLHelper;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.IO;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web;
|
using System.Web.Http;
|
using WebAPI.Code;
|
using WebAPI.Models;
|
namespace WebAPI.Controllers
|
{
|
public class POOrderController : ApiController
|
{
|
private JsonResult objJsonResult = new JsonResult();
|
private json objjson = new json();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
|
/// <summary>
|
/// 采购单列表
|
/// </summary>
|
/// <param name="msg"></param>
|
/// <param name="NowPage"></param>
|
/// <param name="OnePage"></param>
|
/// <returns></returns>
|
[Route("GetPOOrderBill")]
|
[HttpPost]
|
//采购订单列表
|
public object GetPOOrderBill([FromBody] JObject msg)
|
{
|
string HSupIDs = msg["HSupIDs"].ToString(); string sqlWhere = msg["sqlWhere"].ToString();
|
//string msg = "";
|
try
|
{
|
string VsWhere = "";
|
string PcWhere = "";
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet ds;
|
string sql = " Where hsupid in (" + HSupIDs.Trim() + ")" + sqlWhere;
|
//转换特殊字符
|
if (Common.SQLtoChange(sql, ref VsWhere, ref PcWhere) == false)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "转换特殊字符失败";
|
objjson.data = null;
|
return objjson;
|
}
|
//获取总行数
|
//Int64 RowTotal = Common.GetRowTotal("H_v_SRM_POOrderBillList", VsWhere, ref DBUtility.ClsPub.sExeReturnInfo);
|
//获取返回数据
|
//sql = "exec H_P_REALESEPOORDER";
|
//sql = "exec H_P_REALESEPOORDER";
|
//oCn.RunProc(sql);
|
sql = "exec H_p_SRM_POOrderBillList '" + PcWhere + "'";
|
//LogService.WriteAsync(sql);
|
ds = oCn.RunProcReturn("exec H_p_SRM_POOrderBillList '" + PcWhere + "'", "H_p_SRM_POOrderBillList");
|
//添加列名
|
List<object> columnNameList = new List<object>();
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
objjson.code = "0";
|
objjson.count = 10000;
|
objjson.Message = "获取成功";
|
objjson.data = ds.Tables[0];
|
objjson.list = columnNameList;
|
return objjson;
|
|
}
|
catch (Exception e)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + e.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
|
}
|
/// <summary>
|
/// 采购订单表头信息
|
/// </summary>
|
/// <param name="sMsg"></param>
|
/// <returns></returns>
|
[Route("GetPOOrderShowBillMain")]
|
[HttpGet]
|
public object GetPOOrderShowBillMain(string sMsg)
|
{
|
try
|
{
|
DataSet ds;
|
string ShowItem = " * ";//显示的字段
|
if (DBUtility.ClsPub.isLong(sMsg) == 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败";
|
objjson.data = null;
|
return objjson;
|
}
|
DAL.ClsCg_POOrderBill oClsCg_POOrderBill = new DAL.ClsCg_POOrderBill();
|
ds = oClsCg_POOrderBill.ShowBillMainTo(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败";
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 10000;
|
objjson.Message = "获取成功";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception e)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + e.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
/// <summary>
|
/// 采购订单明细表体信息
|
/// </summary>
|
/// <param name="sMsg"></param>
|
/// <param name="sMsg2"></param>
|
/// <returns></returns>
|
[Route("GetPOOrderShowBillSub")]
|
[HttpGet]
|
public object GetPOOrderShowBillSub(string sMsg)
|
{
|
try
|
{
|
DataSet ds = null;
|
string ShowItem = " * ";//显示的字段
|
if (DBUtility.ClsPub.isLong(sMsg) == 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败";
|
objjson.data = null;
|
return objjson;
|
}
|
DAL.ClsCg_POOrderBill oClsCg_POOrderBill = new DAL.ClsCg_POOrderBill();
|
ds = oClsCg_POOrderBill.ShowBillSubTo(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
//return DBUtility.ClsPub.sExeReturnInfo;
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败";
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 10000;
|
objjson.Message = "获取成功";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
//return s;
|
}
|
catch (Exception e)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + e.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
[Route("POOrderAccept")]
|
[HttpPost]
|
/// <summary>
|
/// 订单接受
|
/// </summary>
|
/// <param name="HInterID"></param>
|
/// <returns></returns>
|
public object POOrderAccept([FromBody] JObject oData)
|
{
|
var _value = oData["oData"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string HInter = sArray[0].ToString();
|
string HInterID = HInter.Replace("\"", ""); //内码
|
string HBillNo = sArray[1].ToString().Replace("\"", "");
|
string HUser = sArray[2].ToString(); //用户名
|
|
try
|
{
|
if (DBUtility.ClsPub.isStrNull(HInterID) == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "接受失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
DAL.ClsCg_POOrderBill oBill = new DAL.ClsCg_POOrderBill();
|
oBill.WebAccept(DBUtility.ClsPub.isLong(HInterID), DBUtility.ClsPub.isStrNull(HBillNo), DBUtility.ClsPub.isStrNull(HUser), ref DBUtility.ClsPub.sExeReturnInfo);
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "接受成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "接受失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
[Route("POOrderRefuse")]
|
[HttpGet]
|
/// <summary>
|
/// 订单拒绝
|
/// </summary>
|
/// <param name="HInterID"></param>
|
/// <returns></returns>
|
public object POOrderRefuse(string HInterID, string HBillNo, string HUser, string HBackRemark)
|
{
|
try
|
{
|
if (DBUtility.ClsPub.isLong(HInterID) == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
DAL.ClsCg_POOrderBill oBill = new DAL.ClsCg_POOrderBill();
|
oBill.WebRefuse(DBUtility.ClsPub.isLong(HInterID), DBUtility.ClsPub.isStrNull(HBillNo), DBUtility.ClsPub.isStrNull(HUser), DBUtility.ClsPub.isStrNull(HBackRemark), ref DBUtility.ClsPub.sExeReturnInfo);
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "拒绝成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
[Route("POOrderBack")]
|
[HttpGet]
|
/// <summary>
|
/// 订单反馈状态
|
/// </summary>
|
/// <param name=""></param>
|
/// <returns></returns>
|
public object POOrderBack(string HmainidList, string OrderBackId)
|
{
|
try
|
{
|
string sql = "";
|
for (int i = 0; i < HmainidList.Split(',').Length; i++)
|
{
|
var Hmainid = HmainidList.Split(',')[i];
|
sql = string.Format(@"
|
update Cg_POOrderBillSub set
|
HFeedback ='{0}'
|
where HInterID = '{1}' and HEntryID = '{2}' ", OrderBackId, Hmainid.Split('-')[0], Hmainid.Split('-')[1]);
|
oCn.RunProc(sql);
|
|
}
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "操作成功!";
|
//objJsonResult.Message = string.Join(",", HmainidList.ToArray());
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
[Route("Cg_Poorder/UpdateSupSendGoodsDateRemark")]
|
[HttpGet]
|
/// <summary>
|
/// 更新回复交期 -- 凯贝奈特
|
/// </summary>
|
/// <param name=""></param>
|
/// <returns></returns>
|
public object UpdateSupSendGoodsDateRemark(string HInterID, string HEntryID,string HSupSendGoodsDateRemark)
|
{
|
try
|
{
|
if (HInterID == null || HInterID == "" || HInterID == "undefined" || HEntryID == null || HEntryID == "" || HEntryID == "undefined")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "操作失败!主内码或子内码为空";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
|
string sql = "";
|
|
sql = "update Cg_POOrderBillSub set HSupSendGoodsDateRemark = '" + HSupSendGoodsDateRemark + "' where HInterID = " + HInterID + " and HEntryID = " + HEntryID;
|
oCn.RunProc(sql);
|
|
//凯贝奈特
|
sql = "update AIS20210820164804..T_PUR_POORDERENTRY set F_aaaa_gysjqhf = '" + HSupSendGoodsDateRemark + "' where FID = " + HInterID + " and FENTRYID = " + HEntryID;
|
oCn.RunProc(sql);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "操作成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
}
|
}
|