using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web.Http;
|
using WebAPI.Models;
|
using SyntacticSugar.constant;
|
using Newtonsoft.Json;
|
|
// 组托单/装箱单控制器
|
namespace WebAPI.Controllers.仓存管理
|
{
|
public class Sc_PackUnionBillMain_SettoPackingController : ApiController
|
{
|
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
|
#region 获取组托单
|
/// <summary>
|
/// 获取组托单 有分页
|
/// </summary>
|
/// <returns>组托单列表</returns>
|
[Route("Sc_PackUnionBillMain_SettoPackingController/get_PackUnionBill_SettoListPage")]
|
[HttpGet]
|
public object get_PackUnionBill_SettoListPage(string sWhere, string user, string page, string size)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
if (!DBUtility.ClsPub.Security_Log("Sc_PackUnionBillMain_SettoPacking_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无查看权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
string swhere = (" and 单据类型 = '组托单'" + sWhere).Replace("'", "''");
|
LogService.Write("exec h_p_Sc_PackUnionBillMain_SettoPackingListPage " + page + "," + size + ",N'" + swhere + "'");
|
ds = oCN.RunProcReturn("exec h_p_Sc_PackUnionBillMain_SettoPackingListPage " + page + "," + size + ",N'"+ swhere + "'", "h_p_Sc_PackUnionBillMain_SettoPackingListPage");
|
|
|
//添加列名
|
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列对象的列名
|
}
|
|
objJsonResult.code = CodeConstant.SUCCEED;
|
objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = CodeConstant.FAIL;
|
objJsonResult.count = CountConstant.FAIL;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 获取装箱单
|
/// <summary>
|
/// 获取装箱单 有分页
|
/// </summary>
|
/// <returns>装箱单列表</returns>
|
[Route("Sc_PackUnionBillMain_SettoPackingController/get_PackUnionBill_PackingListPage")]
|
[HttpGet]
|
public object get_PackUnionBill_PackingListPage(string sWhere, string user, string page, string size)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
if (!DBUtility.ClsPub.Security_Log("Sc_PackUnionBillMain_SettoPacking_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无查看权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
string swhere = (" and 单据类型 = '装箱单'" + sWhere).Replace("'", "''");
|
LogService.Write("exec h_p_Sc_PackUnionBillMain_SettoPackingListPage " + page + "," + size + ",N'" + swhere + "'");
|
ds = oCN.RunProcReturn("exec h_p_Sc_PackUnionBillMain_SettoPackingListPage " + page + "," + size + ",N'" + swhere + "'", "h_p_Sc_PackUnionBillMain_SettoPackingListPage");
|
|
|
//添加列名
|
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列对象的列名
|
}
|
|
objJsonResult.code = CodeConstant.SUCCEED;
|
objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = CodeConstant.FAIL;
|
objJsonResult.count = CountConstant.FAIL;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
[Route("Sc_PackUnionBillMain_SettoPackingController/AuditPackUnionBill_Packing")]
|
[HttpGet]
|
public object AuditPackUnionBill_Packing(string HInterID, string user, int Type)
|
{
|
try
|
{
|
//判断是否有审核权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_PackUnionBillMain_SettoPacking_Check", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (string.IsNullOrWhiteSpace(HInterID))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HInterID为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
oCN.BeginTran();//开始事务
|
ds = oCN.RunProcReturn("select top 1 HInterID,HChecker from Sc_PackUnionBillMain where HInterID=" + HInterID, "Sc_PackUnionBillMain");
|
if(ds.Tables.Count < 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (Type == 1) //审核判断
|
{
|
if (string.IsNullOrWhiteSpace(ds.Tables[0].Rows[0]["HChecker"].ToString()) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (Type == 2) //反审核判断
|
{
|
if (string.IsNullOrWhiteSpace(ds.Tables[0].Rows[0]["HChecker"].ToString()) == true)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未审核!不需要反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
//Type 1 审核 2 反审核
|
if (Type == 1)
|
{
|
//审核前控制=========================================
|
ds = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_BeforeCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_BeforeCheckCtrl");
|
if (ds == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
oCN.RunProc("update Sc_PackUnionBillMain set HChecker=N'" + user + "',HCheckDate=getdate() where HInterID=" + HInterID);
|
|
//审核后控制=========================================
|
DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_AfterCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_AfterCheckCtrl");
|
if (ds2 == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核后判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
|
|
}
|
else
|
{
|
//反审核前控制=========================================
|
ds = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_BeforeUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_BeforeUnCheckCtrl");
|
if (ds == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
oCN.RunProc("update Sc_PackUnionBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
|
//反审核后控制=========================================
|
DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_AfterUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_AfterUnCheckCtrl");
|
if (ds2 == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核后判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
|
|
}
|
|
|
oCN.Commit();
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "执行成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "执行失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
}
|
|
[Route("Sc_PackUnionBillMain_SettoPackingController/AuditPackUnionBill_Setto")]
|
[HttpGet]
|
public object AuditPackUnionBill_Setto(string HInterID, string user, int Type)
|
{
|
try
|
{
|
//判断是否有审核权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_PackUnionBillMain_SettoPacking_Check", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (string.IsNullOrWhiteSpace(HInterID))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HInterID为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
oCN.BeginTran();//开始事务
|
ds = oCN.RunProcReturn("select top 1 HInterID,HChecker from Sc_PackUnionBillMain where HInterID=" + HInterID, "Sc_PackUnionBillMain");
|
if (ds.Tables.Count < 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (Type == 1) //审核判断
|
{
|
if (string.IsNullOrWhiteSpace(ds.Tables[0].Rows[0]["HChecker"].ToString()) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (Type == 2) //反审核判断
|
{
|
if (string.IsNullOrWhiteSpace(ds.Tables[0].Rows[0]["HChecker"].ToString()) == true)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未审核!不需要反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
//Type 1 审核 2 反审核
|
if (Type == 1)
|
{
|
//审核前控制=========================================
|
ds = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_BeforeCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_BeforeCheckCtrl");
|
if (ds == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
oCN.RunProc("update Sc_PackUnionBillMain set HChecker=N'" + user + "',HCheckDate=getdate() where HInterID=" + HInterID);
|
|
//审核后控制=========================================
|
DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_AfterCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_AfterCheckCtrl");
|
if (ds2 == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核后判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
|
|
}
|
else
|
{
|
//反审核前控制=========================================
|
ds = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_BeforeUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_BeforeUnCheckCtrl");
|
if (ds == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
oCN.RunProc("update Sc_PackUnionBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
|
//反审核后控制=========================================
|
DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_PackUnionBillMain_SettoPacking_AfterUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Sc_PackUnionBillMain_SettoPacking_AfterUnCheckCtrl");
|
if (ds2 == null)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核后判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//=========================================================
|
|
|
}
|
|
|
oCN.Commit();
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "执行成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "执行失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
}
|
}
|