using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Web.Http;
|
using WebAPI.Models;
|
namespace WebAPI.Controllers
|
{
|
/**
|
* 裁切派工单
|
*/
|
public class Xs_CutWorkSendBillController : ApiController
|
{
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
public WebServer webserver = new WebServer();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
|
|
/// <summary>
|
/// 扫描找货单号获取相关信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("Xs_CutWorkSendBill/getHSEOrderBillNo")]
|
[HttpGet]
|
public object getHSEOrderBillNo(string HSEOrderBillNo)
|
{
|
if (HSEOrderBillNo == null || ("").Equals(HSEOrderBillNo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "请输入找货单号!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
try
|
{
|
ds = getHSEOrderBillNo_s(HSEOrderBillNo);
|
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 = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "返回记录成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 生成裁切派工单
|
/// </summary>
|
/// <returns></returns>
|
[Route("Xs_CutWorkSendBill/set_SaveCutWorkSendBill")]
|
[HttpPost]
|
public object set_SaveCutWorkSendBill([FromBody] JObject oMain)
|
{
|
string oMainData = oMain["oMain"].ToString();
|
oMainData = oMainData.Substring(8, oMainData.Length - 9);
|
try
|
{
|
List<Xs_CutWorkSendBill> lsmain = new List<Xs_CutWorkSendBill>();
|
ListModels oListModels = new ListModels();
|
List<Xs_CutWorkSendBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Xs_CutWorkSendBill>>(oMainData);
|
int HYear = Pub_Class.ClsPub.isInt(DateTime.Now.Year);
|
int HPeriod = Pub_Class.ClsPub.isInt(DateTime.Now.Month);
|
string HBillType = "9191";
|
oCN.BeginTran();
|
var mainSql = "Insert Into Xs_CutWorkSendBillMain " +
|
"(HYear,HPeriod,HBillType,HInterID,HDate" +
|
",HBillNo,HMaker,HMakeDate,HMainSourceBillType" +
|
",HGroupID)" +
|
" values" +
|
"(" + HYear + "," + HPeriod + ",'" + HBillType + "'," + list[0].HInterID + ",GETDATE(),'"
|
+ list[0].HBillNo + "','" + list[0].HMaker + "',GETDATE(),'1401',"
|
+ list[0].HGroupID + ")";
|
oCN.RunProc(mainSql);
|
for (int i = 0; i < list.Count; i++)
|
{
|
var subSql = "Insert Into Xs_CutWorkSendBillSub " +
|
"(HInterID,HBillNo_bak,HSourceInterID,HSourceBillNo,HSourceBillType" +
|
",HSEOrderBillNo,HSEOrderInterID)" +
|
" values" +
|
"(" + list[i].HInterID + ",'" + list[i].HBillNo + "'," + list[i].HMainSourceInterID + ",'" + list[i].HMainSourceBillNo + "','1401','"
|
+ list[i].HMainSourceBillNo + "'," + list[i].HMainSourceInterID + ")";
|
oCN.RunProc(subSql);
|
//反写金蝶销售订单的裁切派工班组
|
var HGroupSql = "update AIS20200908101915zs..T_SAL_ORDERENTRY set F_XSDD_PGSJ=GETDATE(),F_XSDD_PGBZ=(select HName from Gy_Group where HItemID=" + list[i].HGroupID + ") where FID = " + list[i].HMainSourceInterID + "";
|
oCN.RunProc(HGroupSql);
|
}
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "生成找货单成功!单据号为:" + list[0].HBillNo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "上传失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
/// <summary>
|
/// 上下架单列表
|
/// </summary>
|
/// <returns></returns>
|
[Route("Xs_CutWorkSendBill/List")]
|
[HttpGet]
|
public object List(string sWhere)
|
{
|
try
|
{
|
ds = List_s(sWhere);
|
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 = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "返回记录成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
|
|
#region sql语句
|
|
public static DataSet getHSEOrderBillNo_s(string HSEOrderBillNo)
|
{
|
return new SQLHelper.ClsCN().RunProcReturn(
|
"select FID HMainSourceInterID,FBILLNO HMainSourceBillNo,1 pages,'' HMaker from AIS20200908101915zs..T_SAL_ORDER where FBILLNO ='" + HSEOrderBillNo + "'"
|
, "AIS20200908101915zs..T_SAL_ORDER");
|
}
|
public static DataSet List_s(string sWhere)
|
{
|
return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Xs_CutWorkSendBillList where 1=1 " + sWhere , "h_v_Xs_CutWorkSendBillList");
|
}
|
|
|
#endregion
|
|
}
|
}
|