using Model;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.IO;
|
using System.Web;
|
using System.Web.Http;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers
|
{
|
public class Gy_SplitBarCodeController : ApiController
|
{
|
//获取系统参数
|
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public DAL.ClsGy_BarCodeBill_ChaiMa BillNew = new DAL.ClsGy_BarCodeBill_ChaiMa(); //对应单据类
|
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
|
/// <summary>
|
/// 返回条码信息
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Gy_SplitBarCode/Info")]
|
[HttpGet]
|
public object BarCodeInfo(string HBarCodeNo, string HSplitBarNum)
|
{
|
try
|
{
|
//判断是否有查询权限
|
|
//if (!DBUtility.ClsPub.Security_Log("Cg_POOrderBillQuery", 1, false, user))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "无权限查看!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
//查询条码信息
|
if(HBarCodeNo != null && HSplitBarNum != null)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
ds = oCn.RunProcReturn("select top 1 * from h_v_Gy_SplitBarCode where HBarCode='" + HBarCodeNo + "'", "h_v_Gy_SplitBarCode");
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "请输入条码编号或拆分条码数";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
//判断是否存在此条码
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "条码编号不存在, 提示";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception e) //抛出异常
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#region 拆码条码生成
|
[Route("Sc_BarCode/Save_SplitBarCode")]
|
[HttpPost]
|
public object Save_SplitBarCode([FromBody] JObject msg)
|
{
|
try
|
{
|
ListModels oListModels = new ListModels();
|
BillNew = new DAL.ClsGy_BarCodeBill_ChaiMa();
|
var _value = msg["msg"].ToString();
|
string msg1 = _value.ToString();
|
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string barcode = sArray[0].ToString(); //条码编号
|
Int64 splitnum = Convert.ToInt64(sArray[1]); //拆码行数
|
string data = sArray[2].ToString(); //表体数据
|
string user = sArray[3].ToString(); //用户名
|
|
data = data.Replace("\\", "");
|
data = data.Replace("\n", ""); //\n
|
|
List<Model.ClsGy_BarCodeEdit_Model> lsmain = new List<Model.ClsGy_BarCodeEdit_Model>();
|
lsmain = oListModels.getObjectByJson_Gy_SplitBarCode(data);
|
|
oCN.BeginTran();
|
|
ds = oCN.RunProcReturn("select top 1* from Gy_BarCodeBill where HBarCode='" + barcode + "'", "Gy_BarCodeBill");
|
|
bool bResult = true;
|
|
if (ds != null || ds.Tables[0].Rows.Count > 0)
|
{
|
Model.ClsGy_BarCodeEdit_Model model = new Model.ClsGy_BarCodeEdit_Model();
|
for (Int64 i = 0; i < splitnum; i++)
|
{
|
model.HEntryID = i + 1;
|
model.HInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"].ToString());
|
model.HBarCode = DBUtility.ClsPub.isStrNull(lsmain[Convert.ToInt32(i)].HBarCode);
|
model.HQty = DBUtility.ClsPub.isLong(lsmain[Convert.ToInt32(i)].HSplitNum);
|
model.HQty = DBUtility.ClsPub.isInt(lsmain[Convert.ToInt32(i)].HSplitNum);
|
model.HBatchNo = DBUtility.ClsPub.isStrNull(lsmain[Convert.ToInt32(i)].HBatchNo);
|
model.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HMaterID"].ToString());
|
model.HUnitID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HUnitID"].ToString());
|
model.HSupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HSupID"].ToString());
|
model.HDeptID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HDeptID"].ToString());
|
model.HEmpID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HEmpID"].ToString());
|
model.HBarCodeType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBarCodeType"].ToString());
|
model.HItemSubID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HItemSubID"].ToString());
|
model.HGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HGroupID"].ToString());
|
model.HSourceInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceInterID"].ToString());
|
model.HSourceEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceEntryID"].ToString());
|
model.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HSourceBillNo"].ToString());
|
model.HSourceBillType = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HSourceBillType"].ToString());
|
model.HUseFlag = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HUseFlag"].ToString());
|
model.HInitQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[0]["HInitQty"].ToString());
|
model.HSourceID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInitQty"].ToString());
|
model.HCusID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCusID"].ToString());
|
model.HSTOCKORGID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HSTOCKORGID"].ToString());
|
model.HOWNERID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HOWNERID"].ToString());
|
model.HBarCodeDate = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["HBarCodeDate"].ToString());
|
model.HInnerBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HInnerBillNo"].ToString());
|
model.HMZ = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[0]["HMZ"].ToString());
|
|
model.HMakeDate = DateTime.Now;
|
model.HMaker = user;
|
|
BillNew.DetailColl_Mater.Add(model);
|
|
//保存
|
bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo, barcode);
|
|
BillNew.DetailColl_Mater.Remove(model);
|
}
|
|
}
|
|
if (bResult)
|
{
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "保存成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
else
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
}
|
}
|