using DAL;
|
using DBUtility;
|
using Microsoft.AspNet.SignalR;
|
using Model;
|
using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using SQLHelper;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web;
|
using System.Web.Http;
|
using WebAPI.BLL;
|
using WebAPI.Models;
|
using WebAPI.Utility;
|
|
namespace WebAPI.Controllers
|
{
|
public class WebAPIController : ApiController
|
{
|
private JsonResult objJsonResult = new JsonResult();
|
private json objjson = new json();
|
// private POInStockBillServices oclscg_poinstockbillmain = new POInStockBillServices();
|
public string sWhere = "";
|
public WebServer webserver = new WebServer();
|
public DataSet ds = new DataSet();
|
|
public static string GetSession(string sMsg)
|
{
|
try
|
{
|
string s = Common.GetSession();
|
return s;
|
}
|
catch (Exception e)
|
{
|
return "";
|
}
|
}
|
/// <summary>
|
/// 写入日志
|
/// </summary>
|
public static bool Add_Log(string WorkList, string CurUserName, string State)
|
{
|
|
DBUtility.ClsPub.SetIPAddress();
|
string IPAddress;
|
string ComputerName;
|
IPAddress = DBUtility.ClsPub.IPAddress;
|
ComputerName = DBUtility.ClsPub.ComputerName;
|
ClsCNSRM oCnLoc = new ClsCNSRM();
|
try
|
{
|
oCnLoc.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
|
"(getdate(),'" + CurUserName + "','" + ComputerName + "','" + WorkList + "','SRM系统','" + IPAddress + "','" + State + "')"
|
);
|
|
return true;
|
}
|
catch (Exception e)
|
{
|
return false;
|
|
}
|
|
}
|
/// <summary>
|
/// 日志列表
|
/// </summary>
|
/// <param name="msg"></param>
|
/// <param name="NowPage"></param>
|
/// <param name="OnePage"></param>
|
/// <returns></returns>
|
[Route("GetSystemLog")]
|
[HttpGet]
|
//送货单列表
|
public object GetSystemLog(string HSupNo, string sqlWhere)
|
{
|
string msg = "";
|
try
|
{
|
string VsWhere = "";
|
string PcWhere = "";
|
SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
|
DataSet ds;
|
//其他过滤
|
if (msg.Trim() == "")
|
{
|
msg = " Where 用户名=^^" + HSupNo.Trim() + "^^ " + sqlWhere;
|
// msg = " Where hsupid in (select hsupid from Gy_UserSupplierRelation where HUserID=^^" + System.Web.HttpContext.Current.Session["HUserName"].ToString() + "^^)";
|
}
|
else
|
{
|
msg = msg + " and 用户名=^^" + HSupNo.Trim() + "^^" + sqlWhere;
|
// msg = msg + " Where hsupid in (select hsupid from Gy_UserSupplierRelation where HUserID=^^" + System.Web.HttpContext.Current.Session["HUserName"].ToString() + "^^)";
|
}
|
//转换特殊字符
|
if (Common.SQLtoChange(msg, 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_SystemLogList", VsWhere, ref DBUtility.ClsPub.sExeReturnInfo);
|
//获取返回数据
|
ds = oCn.RunProcReturn("exec h_p_SRM_SystemLogList '" + PcWhere + "'", "h_p_SRM_SystemLogList");
|
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>
|
/// <returns></returns>
|
[Route("GetOrganizations")]
|
[HttpGet]
|
public object GetOrganizations()
|
{
|
try
|
{
|
ClsCN oCn = new ClsCN();
|
DataSet oDs = new DataSet();
|
//==========
|
oDs = oCn.RunProcReturn("select HItemID ID,Hname Name,HStopflag Stopflag from Xt_ORGANIZATIONS", "Xt_ORGANIZATIONS");
|
objjson.code = "1";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = oDs.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="UserName">用户名</param>
|
/// <param name="PassWord">密码</param>
|
/// <returns></returns>
|
[Route("GetUser")]
|
[HttpGet]
|
public object GetUser(string UserName, string PassWord)
|
{
|
try
|
{
|
DataSet ds = null;
|
ClsCNSRM oCnLoc = new ClsCNSRM();
|
DAL.ClsUser oUser = new DAL.ClsUser();
|
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
|
//LogService.Write("测试1:"+ DBUtility.ClsPub.sExeReturnInfo);
|
string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);
|
LogService.Write(FCusName);
|
LogService.Write("DBUtility.ClsPub.StrToPsd(PassWord.Trim()):" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()));
|
//if (FCusName == "夏宝电器")
|
// ds = CheckMainID(UserName.Trim(), DBUtility.ClsPub.StrToPsd(PassWord.Trim()));
|
//else
|
// ds = CheckCzymc(UserName.Trim(), DBUtility.ClsPub.StrToPsd(PassWord.Trim()));
|
|
ds = CheckMainID(UserName.Trim(), DBUtility.ClsPub.StrToPsd(PassWord.Trim()));
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "密码错误!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "登录成功!";
|
objJsonResult.data = ds.Tables[0];
|
Add_Log("主界面", UserName, "登录");
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "登录异常!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
}
|
public DataSet CheckMainID(string MainID, string sPsd)
|
{
|
DataSet DS;
|
try
|
{
|
SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
|
DS = oCn.RunProcReturn("select * from Gy_Czygl where Czybm='" + MainID + "' and Czmm='" + sPsd + "' ", "Gy_Czygl");
|
if (DS.Tables[0].Rows.Count == 0)
|
return null;
|
else
|
{
|
return DS;
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
public DataSet CheckCzymc(string sUser, string sPsd)
|
{
|
SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
|
SqlParameter[] prams ={oCn.MakeInParam("@Czymc",SqlDbType.VarChar,100,sUser ),
|
oCn.MakeInParam("@Czmm",SqlDbType.VarChar ,100,sPsd ),
|
};
|
return oCn.RunProcReturn("select * from Gy_Czygl where Czymc='" + sUser + "' and Czmm='" + sPsd + "' ", prams, "Gy_Czygl");
|
}
|
|
/// <summary>
|
/// 修改密码
|
/// </summary>
|
/// <param name="UserName"></param>
|
/// <param name="PassWord"></param>
|
/// <returns></returns>
|
[Route("GetXGPassword")]
|
[HttpGet]
|
public object GetXGPassword(string UserName, string oldPassword, string PassWord, string Repassword)
|
{
|
try
|
{
|
ClsCNSRM oCn = new ClsCNSRM();
|
DataSet oDs = new DataSet();
|
//==========
|
if (PassWord.Trim() != Repassword.Trim())
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "2次密码不一致!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
//===========
|
//LogService.Write("select Czmm from Gy_Czygl where Czymc='" + UserName + "' and Czmm = '" + DBUtility.ClsPub.StrToPsd(oldPassword.Trim()) + "'");
|
oDs = oCn.RunProcReturn("select Czmm from Gy_Czygl where Czymc='" + UserName + "' and Czmm = '" + DBUtility.ClsPub.StrToPsd(oldPassword.Trim()) + "'", "Gy_Czygl");
|
if (oDs == null || oDs.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "原密码错误!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
else
|
{
|
oCn.RunProc("update Gy_Czygl set Czmm='" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()) + "' where Czymc='" + UserName.Trim() + "'");
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "* 密码修改成功!";
|
objJsonResult.data = null;
|
Add_Log("主界面", UserName, "修改密码");
|
return objJsonResult; ;
|
}
|
}
|
catch (Exception)
|
{
|
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "修改密码异常!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
}
|
///// <summary>
|
///// 确认交期
|
///// </summary>
|
///// <param name="HInterID"></param>
|
///// <param name="HEntryID"></param>
|
///// <param name="HState"></param>
|
///// <returns></returns>
|
//[Route("UpdateBill")]
|
//[HttpGet]
|
//public object UpdateBill(int HInterID, int HEntryID, int HState)
|
//{
|
// try
|
// {
|
// if (DBUtility.ClsPub.isLong(HInterID) == 0)
|
// {
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "N,项目不存在!";
|
// objJsonResult.data = 1;
|
// return objJsonResult;
|
// }
|
// DAL.ClsKf_POStockInBill_K3 oBill = new DAL.ClsKf_POStockInBill_K3();
|
// if (oBill.UpdateBill(HInterID, HEntryID, HState) == "Y")
|
// {
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 1;
|
// objJsonResult.Message = "确认成功!";
|
// objJsonResult.data = 1;
|
// return objJsonResult;
|
// }
|
// else
|
// {
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "确认失败!";
|
// objJsonResult.data = 1;
|
// return objJsonResult;
|
// }
|
// }
|
// catch (Exception e)
|
// {
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "确认失败!" + e.ToString();
|
// objJsonResult.data = 1;
|
// return objJsonResult;
|
// }
|
//}
|
|
/// <summary>
|
/// 获取打印模板列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetOpenTmpList_Json")]
|
[HttpGet]
|
public object GetOpenTmpList_Json(string HNumber)
|
{
|
sWhere = " Where 1=1 ";
|
//sWhere = " Where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
|
if (HNumber != "")
|
{
|
sWhere = sWhere + " and ( HNumber = '" + HNumber + "') ";
|
}
|
try
|
{
|
ds = webserver.GetOpenTmpList(sWhere, ref DBUtility.ClsPub.sErrInfo);
|
if (ds == null || ds.Tables[0].Rows.Count <= 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + ex.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
/// <summary>
|
/// 保存打印模板
|
/// </summary>
|
/// <returns></returns>
|
[Route("SaveOpenTmp")]
|
[HttpGet]
|
public object SaveOpenTmp(string HNumber, string HName)
|
{
|
ClsCNSRM oCn = new ClsCNSRM();
|
try
|
{
|
|
//oCn.BeginTran();
|
//oCn.RunProc("Insert into SRM_OpenTmp " +
|
// " (HNumber,HModel,HName) " +
|
// " Values('" + HNumber + "','" + HName + "','" + HName + "')", ref DBUtility.ClsPub.sExeReturnInfo);
|
////修改上级为非末级代码
|
////oCn.RunProc("Update Gy_OpenTmp set HEndflag=0 where HItemID=" + oModel.HParentID, ref ClsPub.sExeReturnInfo);
|
//oCn.Commit();
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "保存成功!";
|
objjson.data = null;
|
return objjson;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "保存失败" + e.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
|
|
}
|
/// <summary>
|
/// 删除印模板
|
/// </summary>
|
/// <returns></returns>
|
[Route("DelOpenTmp")]
|
[HttpGet]
|
public object DelOpenTmp(string HItemID)
|
{
|
ClsCNSRM oCn = new ClsCNSRM();
|
try
|
{
|
//oCn.BeginTran();
|
//oCn.RunProc("Delete from SRM_OpenTmp where HItemID='" + DBUtility.ClsPub.isLong(HItemID) + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
//oCn.Commit();
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "删除成功!";
|
objjson.data = null;
|
return objjson;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "删除失败" + e.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
|
}
|
#region 基础资料
|
/// <summary>
|
/// 获取仓库列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetWarehouseList_Json")]
|
[HttpGet]
|
public object GetWarehouseList_Json(string Warehouse)
|
{
|
sWhere = " Where HStopFlag=0 and HEndFlag=1";
|
//sWhere = " Where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
|
if (Warehouse != "")
|
{
|
sWhere = sWhere + " and ( HNumber like '%" + Warehouse + "%' or HName like '%" + Warehouse + "%' ) ";
|
}
|
try
|
{
|
ds = webserver.GetWarehouseList(sWhere, ref DBUtility.ClsPub.sErrInfo);
|
if (ds == null || ds.Tables[0].Rows.Count <= 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + ex.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
/// <summary>
|
/// 获取仓位列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetStockPlaceList_Json")]
|
[HttpGet]
|
public object GetStockPlaceList_Json(string StockPlace, Int64 HWhID)
|
{
|
sWhere = " Where HStopFlag=0 and HEndFlag=1";
|
//sWhere = " Where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
|
if (HWhID == 0)
|
{
|
if (StockPlace != "")
|
{
|
sWhere = " Where HStopFlag=0 and ( HNumber like '%" + StockPlace + "%' or HName like '%" + StockPlace + "%' ) ";
|
}
|
else
|
{
|
sWhere = " Where HStopFlag=0 ";
|
}
|
}
|
else
|
{
|
if (StockPlace != "")
|
{
|
sWhere = " Where HStopFlag=0 and HWHID=" + HWhID.ToString() + " and ( HNumber like '%" + StockPlace + "%' or HName like '%" + StockPlace + "%' ) ";
|
}
|
else
|
{
|
sWhere = " Where HStopFlag=0 and HWHID=" + HWhID.ToString();
|
}
|
}
|
try
|
{
|
ds = webserver.GetStockPlaceList(sWhere, ref DBUtility.ClsPub.sErrInfo);
|
if (ds == null || ds.Tables[0].Rows.Count <= 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + ex.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
/// <summary>
|
/// 获取供应商列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetSupplierList_Json")]
|
[HttpGet]
|
public object GetSupplierList_Json(string Supplier)
|
{
|
sWhere = " Where HStopFlag=0 and HEndFlag=1";
|
//sWhere = " Where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
|
if (Supplier != "")
|
{
|
sWhere = sWhere + " and ( HNumber like '%" + Supplier + "%' or HName like '%" + Supplier + "%' ) ";
|
}
|
try
|
{
|
ds = webserver.GetSupplierList(sWhere, ref DBUtility.ClsPub.sErrInfo);
|
if (ds == null || ds.Tables[0].Rows.Count <= 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + ex.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
/// <summary>
|
/// 获取客户列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetCustomerList_Json")]
|
[HttpGet]
|
public object GetCustomerList_Json(string Customer)
|
{
|
sWhere = " Where HStopFlag=0 and HEndFlag=1";
|
//sWhere = " Where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
|
if (Customer != "")
|
{
|
sWhere = sWhere + " and ( HNumber like '%" + Customer + "%' or HName like '%" + Customer + "%' ) ";
|
}
|
try
|
{
|
ds = webserver.GetCustomerList(sWhere, ref DBUtility.ClsPub.sErrInfo);
|
if (ds == null || ds.Tables[0].Rows.Count <= 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + ex.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
|
/// <summary>
|
/// 获取职员列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetEmployeeList_Json")]
|
[HttpGet]
|
public object GetEmployeeList_Json(string Employee, Int64 HGroupID)
|
{
|
sWhere = " Where HStopFlag=0 and HEndFlag=1";
|
//sWhere = " Where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
|
if (HGroupID == 0)
|
{
|
if (Employee != "")
|
{
|
sWhere = " Where HStopFlag=0 and ( HNumber like '%" + Employee + "%' or HName like '%" + Employee + "%' ) ";
|
}
|
else
|
{
|
sWhere = " Where HStopFlag=0 ";
|
}
|
}
|
else
|
{
|
if (Employee != "")
|
{
|
sWhere = " Where HStopFlag=0 and HWHID=" + HGroupID.ToString() + " and ( HNumber like '%" + Employee + "%' or HName like '%" + Employee + "%' ) ";
|
}
|
else
|
{
|
sWhere = " Where HStopFlag=0 and HWHID=" + HGroupID.ToString();
|
}
|
}
|
try
|
{
|
ds = webserver.GetEmployeeList(sWhere, ref DBUtility.ClsPub.sErrInfo);
|
if (ds == null || ds.Tables[0].Rows.Count <= 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + ex.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
/// <summary>
|
/// 获取部门列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetDepartmentList_Json")]
|
[HttpGet]
|
public object GetDepartmentList_Json(string Department)
|
{
|
sWhere = " Where HStopFlag=0 and HEndFlag=1";
|
//sWhere = " Where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
|
if (Department != "")
|
{
|
sWhere = sWhere + " and ( HNumber like '%" + Department + "%' or HName like '%" + Department + "%' ) ";
|
}
|
try
|
{
|
ds = webserver.GetDepartmentList(sWhere, ref DBUtility.ClsPub.sErrInfo);
|
if (ds == null || ds.Tables[0].Rows.Count <= 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功!";
|
objjson.data = ds.Tables[0];
|
return objjson;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + ex.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
#endregion
|
|
|
/// <summary>
|
/// 触发hub的api
|
/// </summary>
|
/// <param name="request">request</param>
|
/// <returns>message</returns>
|
[AllowAnonymous]
|
[Route("show/hub"), HttpGet]
|
public HttpResponseMessage GetMessage(HttpRequestMessage request)
|
{
|
var hub = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
|
//注意这里的showMessage 就是对RepairHub下定义的showMessage方法调用,同样前端也是调用这个方法
|
string aa = hub.Clients.All.showMessage("这里面可以放入任意对象,前台可以收到此内容");
|
return request.CreateResponse(HttpStatusCode.OK, aa);
|
}
|
|
[Route("Message/MsgCount")]
|
[HttpPost]
|
public object MsgCount()
|
{
|
ClsCNSRM oCn = new ClsCNSRM();
|
DataSet oDs = new DataSet();
|
oDs = oCn.RunProcReturn("select * from Gy_Message", "Gy_Message");
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "返回数据";
|
objJsonResult.data = oDs;
|
return objJsonResult; ;
|
}
|
|
|
#region [公告数据查询]
|
[Route("MsgData")]
|
[HttpGet]
|
public object MsgData(string sWhere)
|
{
|
ClsCNSRM oCn = new ClsCNSRM();
|
DataSet oDs = new DataSet();
|
var sql = "select A.HInterID,b.HEntryID,A.HContext,A.HDeptID,D.HName HDeptName, A.HSendMan, B.HReceiveMan,A.HLevel,A.HDescription,case when B.HReadFlag=0 then '未阅' when B.HReadFlag=1 then '已阅' end HReadFlag,A.HDate" +
|
" from OA_InformBillMain A inner join OA_InformBillSub B on A.HInterID=B.HInterID left join Gy_Department D on A.HDeptID=D.HItemID where 1=1 " + sWhere;
|
oDs = oCn.RunProcReturn(sql, "OA_InformBillMain");
|
if (oDs.Tables[0].Rows.Count > 0)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "返回数据成功!";
|
objJsonResult.data = oDs;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "返回数据失败!";
|
objJsonResult.data = oDs;
|
}
|
return objJsonResult; ;
|
}
|
#endregion
|
|
#region[更改公告状态]
|
[Route("UpdateMessage")]
|
[HttpGet]
|
public object UpdateMessage(string UserName, string HInterID, string HEntryID)
|
{
|
ClsCNSRM oCn = new ClsCNSRM();
|
oCn.BeginTran();
|
oCn.RunProc("Update OA_InformBillSub set HReadFlag=1 HUpDater='" + UserName + "',HUpDateDate=getdate() where HInterID='" + HInterID + "' and HEntryID='" + HEntryID + "'", ref Pub_Class.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
objjson.code = "1";
|
objjson.count = 1;
|
objjson.Message = Pub_Class.ClsPub.sExeReturnInfo;
|
objjson.data = null;
|
return objjson; ;
|
}
|
#endregion
|
#region[打印idSession]
|
[Route("linteridSession")]
|
[HttpPost]
|
public object linteridSession([FromBody] JObject linterid)
|
{
|
var _linterid = linterid["linterid"].ToString();
|
var _huserName = linterid["HUserName"].ToString();
|
var postMesseege = _linterid + ";" + _huserName;
|
//HttpHelper.PostData("http://localhost:8082/ZYMES/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege);
|
HttpHelper.PostData("http://60.191.21.115:9090/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege);
|
SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
|
string sql = $"Update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0) + 1 where HItemID in ({_linterid})";
|
oCn.RunProc(sql);
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
|
//HttpContext.Current.Session["linterid"];
|
|
}
|
#endregion
|
|
/// <summary>
|
/// 表头信息
|
/// </summary>
|
/// <param name="sMsg"></param>
|
/// <returns></returns>
|
[Route("Web/GetMAXNum")]
|
[HttpGet]
|
public object GetMAXNum(string HBillType)
|
{
|
try
|
{
|
string HBillNo = "";
|
Int64 HInterID = 0;//显示的字段
|
HInterID = DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
|
HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
|
//----------创建虚表------------------------
|
DataTable dt_Main = new DataTable("Json");
|
dt_Main.Columns.Add("HBillNo", typeof(string));
|
dt_Main.Columns.Add("HInterID", typeof(int));
|
//---------创建新行------------------------
|
DataRow dr_main = dt_Main.NewRow();//创建新行
|
dt_Main.Rows.Add(dr_main);//将新行加入到表中
|
dr_main["HBillNo"] = DBUtility.ClsPub.isStrNull(HBillNo);
|
dr_main["HInterID"] = DBUtility.ClsPub.isLong(HInterID);
|
|
if (HBillNo == null || HInterID == 0)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败";
|
objjson.data = null;
|
return objjson;
|
}
|
else
|
{
|
objjson.code = "0";
|
objjson.count = 1;
|
objjson.Message = "获取成功";
|
objjson.data = dt_Main;
|
return objjson;
|
}
|
}
|
catch (Exception e)
|
{
|
objjson.code = "0";
|
objjson.count = 0;
|
objjson.Message = "获取失败" + e.ToString();
|
objjson.data = null;
|
return objjson;
|
}
|
}
|
|
//得到最大HINTERID
|
public static Int64 CreateBillID(string BillCode, ref string sReturn)
|
{
|
string BillType = "";
|
DataSet Ds;
|
ClsSqlHelper oCn = new ClsSqlHelper();
|
Int64 lID;
|
Ds = oCn.RunProcReturn("select * from Gy_BillNumber with (nolock) where BillCode='" + BillCode.Trim() + "'", "Gy_BillNumber");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lID = Pub_Class.ClsPub.isLong(Ds.Tables[0].Rows[0]["IDNow"].ToString());
|
BillType = Ds.Tables[0].Rows[0]["BillType"].ToString().Trim();
|
}
|
else
|
{
|
lID = 0;
|
}
|
//同类型单据 自增1
|
if (BillType.Trim() != "")
|
{
|
oCn.RunProc("update Gy_BillNumber set IDNow=IDNow+1 where BillType='" + BillType.Trim() + "'");
|
}
|
oCn.CnClose();
|
oCn.CnDispose();
|
oCn = null;
|
Ds = null;
|
return lID;
|
}
|
|
//得到最大单据号
|
public static string CreateBillCode(string BillCode, ref string sReturn, bool Add)
|
{
|
Int64 BillCodeMode;
|
string Profix;
|
Int64 Glida;
|
Int32 CodeLen;
|
string sBillNo = "";
|
char c = Convert.ToChar("0");
|
string sKjYear = DateTime.Today.Year.ToString();
|
string sPeriod = DateTime.Today.Month.ToString();
|
string sDay = DateTime.Today.Day.ToString();
|
//得到单据号表 信息
|
ClsSqlHelper oCn = new ClsSqlHelper();
|
DataSet Ds = new DataSet();
|
Ds = oCn.RunProcReturn("Select * from Gy_BillNumber where BillCode='" + BillCode.Trim() + "'", "Gy_BillNumber");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
BillCodeMode = Pub_Class.ClsPub.isLong(Ds.Tables[0].Rows[0]["BillCodeMode"].ToString());
|
Profix = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["Profix"].ToString());
|
Glida = Pub_Class.ClsPub.isLong(Ds.Tables[0].Rows[0]["Glida"].ToString());
|
CodeLen = Pub_Class.ClsPub.isInt(Ds.Tables[0].Rows[0]["CodeLen"].ToString());
|
}
|
else
|
{
|
return "";
|
}
|
//
|
string sStr;
|
switch (BillCodeMode)
|
{
|
case 0:
|
switch (Glida)
|
{
|
case 0://纯流水号
|
Ds = oCn.RunProcReturn("Select * from Gy_MaxNum where BillCode='" + BillCode.Trim() + "'", "Gy_MaxNum");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["NowNumBer"].ToString()).Length);
|
sBillNo = Profix.Trim() + sStr + Ds.Tables[0].Rows[0]["NowNumBer"].ToString().Trim();
|
}
|
else //插入新记录
|
{
|
sStr = new string(c, CodeLen - 1);
|
oCn.RunProc("insert into Gy_MaxNum(BillCode,NowNumber) values('" + BillCode.Trim() + "',1)");
|
sBillNo = Profix.Trim() + sStr + 1;
|
}
|
if (Add == true)
|
{
|
oCn.RunProc("update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" + BillCode.Trim() + "'");
|
}
|
return sBillNo;
|
|
case 1://根据 YY年+MM月 日 + 流水号 生成单据号 (日 采用了 仓库的字段)
|
sKjYear = sKjYear.Substring(2, 2);
|
sPeriod = "0" + sPeriod;
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
sDay = "";
|
Ds = oCn.RunProcReturn("Select * from Gy_MaxNum where BillCode='" + BillCode.Trim() + "' and KjYear='" + sKjYear + "' and Period='" + sPeriod + "' and whcode='" + sDay + "'", "Gy_MaxNum");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["NowNumBer"].ToString()).Length);
|
sBillNo = Profix.Trim() + sKjYear + sPeriod + sDay + sStr + Ds.Tables[0].Rows[0]["NowNumBer"].ToString().Trim();
|
}
|
else //插入新记录
|
{
|
sStr = new string(c, CodeLen - 1);
|
oCn.RunProc("insert into Gy_Maxnum(BillCode,Kjyear,Period,whcode,NowNumber) values('" + BillCode.Trim() + "','" + sKjYear + "','" + sPeriod + "','" + sDay + "',1)");
|
sBillNo = Profix.Trim() + sKjYear + sPeriod + sDay + sStr + "1";
|
}
|
if (Add == true)
|
{
|
oCn.RunProc("update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" + BillCode.Trim() + "' and KjYear='" + sKjYear + "' and Period='" + sPeriod + "' and whcode='" + sDay + "'");
|
}
|
return sBillNo;
|
case 2: //根据年+月+日 生成单据号
|
Ds = oCn.RunProcReturn("Select * from Gy_MaxNum where BillCode='" + BillCode.Trim() + "' and KjYear='" + sKjYear + "' and Period='" + sPeriod + "' and whcode='" + sDay + "'", "Gy_MaxNum");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["NowNumBer"].ToString()).Length);
|
sBillNo = Profix.Trim() + sKjYear + Pub_Class.ClsPub.isStrNull(("0" + sPeriod)).Substring(Pub_Class.ClsPub.isStrNull(("0" + sPeriod)).Length - 2, 2) + Pub_Class.ClsPub.isStrNull(("0" + sDay)).Substring(Pub_Class.ClsPub.isStrNull(("0" + sDay)).Length - 2, 2) + sStr + Ds.Tables[0].Rows[0]["NowNumBer"].ToString().Trim();
|
}
|
else //插入新记录
|
{
|
sStr = new string(c, CodeLen - 1);
|
oCn.RunProc("insert into Gy_Maxnum(BillCode,Kjyear,Period,whcode,NowNumber) values('" + BillCode.Trim() + "','" + sKjYear + "','" + sPeriod + "','" + sDay + "',1)");
|
sBillNo = Profix.Trim() + sKjYear + Pub_Class.ClsPub.isStrNull(("0" + sPeriod)).Substring(Pub_Class.ClsPub.isStrNull(("0" + sPeriod)).Length - 2, 2) + Pub_Class.ClsPub.isStrNull(("0" + sDay)).Substring(Pub_Class.ClsPub.isStrNull(("0" + sDay)).Length - 2, 2) + sStr + 1;
|
}
|
if (Add == true)
|
{
|
oCn.RunProc("update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" + BillCode.Trim() + "' and KjYear='" + sKjYear + "' and Period='" + sPeriod + "' and whcode='" + sDay + "'");
|
}
|
return sBillNo;
|
case 3: //根据 乔一 (S + 年(23)+五位流水号)实例:S2300001
|
Ds = oCn.RunProcReturn("Select * from Gy_MaxNum where BillCode='" + BillCode.Trim() + "' and KjYear='0' and whcode=''", "Gy_MaxNum");
|
sKjYear = sKjYear.Substring(2, 2);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["NowNumBer"].ToString()).Length);
|
Profix = Profix.Substring(0, 1);
|
sBillNo = Profix.Trim() + sKjYear + sStr + Ds.Tables[0].Rows[0]["NowNumBer"].ToString().Trim();
|
}
|
else //插入新记录
|
{
|
sStr = new string(c, CodeLen - 1);
|
oCn.RunProc("insert into Gy_Maxnum(BillCode,Kjyear,Period,whcode,NowNumber) values('" + BillCode.Trim() + "','" + sKjYear + "','" + sPeriod + "','" + sDay + "',1)");
|
sBillNo = Profix.Trim() + sKjYear + sStr + 1;
|
}
|
if (Add == true)
|
{
|
oCn.RunProc("update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" + BillCode.Trim() + "' and KjYear='0' and whcode=''");
|
}
|
return sBillNo;
|
case 4: //根据 乔一 工序流转卡号改成年+月+四位流水号(23050001)
|
Ds = oCn.RunProcReturn("Select * from Gy_MaxNum where BillCode='" + BillCode.Trim() + "' and KjYear='0' and whcode=''", "Gy_MaxNum");
|
sKjYear = sKjYear.Substring(2, 2);
|
sPeriod = "0" + sPeriod;
|
sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["NowNumBer"].ToString()).Length);
|
sBillNo = sKjYear + sPeriod + sStr + Ds.Tables[0].Rows[0]["NowNumBer"].ToString().Trim();
|
}
|
else //插入新记录
|
{
|
sStr = new string(c, CodeLen - 1);
|
oCn.RunProc("insert into Gy_Maxnum(BillCode,Kjyear,Period,whcode,NowNumber) values('" + BillCode.Trim() + "','" + sKjYear + "','" + sPeriod + "','" + sDay + "',1)");
|
sBillNo = sKjYear + sPeriod + sStr + 1;
|
}
|
if (Add == true)
|
{
|
oCn.RunProc("update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" + BillCode.Trim() + "' and KjYear='0' and whcode=''");
|
}
|
return sBillNo;
|
default:
|
return sBillNo;
|
|
}
|
|
case 1:
|
return sBillNo;
|
|
default:
|
return sBillNo;
|
|
}
|
oCn.CnClose();
|
oCn.CnDispose();
|
oCn = null;
|
}
|
|
}
|
}
|