using DBUtility;
|
using Model;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Linq;
|
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;
|
|
namespace WebAPI.Controllers.仓存管理.条码生成
|
{
|
public class Gy_BarCodeBill_OutController : ApiController
|
{
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
|
#region [条码归档列表]
|
[Route("Gy_BarCodeBill_Out/list")]
|
[HttpGet]
|
public object list(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_Gy_BarCodeBill_OutList order by HMainID asc", "h_v_Gy_BarCodeBill_OutList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_Gy_BarCodeBill_OutList where 1 = 1 ";
|
string sql = sql1 + sWhere + " order by HMainID asc";
|
ds = oCN.RunProcReturn(sql, "h_v_Gy_BarCodeBill_OutList");
|
}
|
foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用
|
{
|
Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region [根据ID查找记录]
|
[Route("Gy_BarCodeBill_Out/cx")]
|
[HttpGet]
|
public object cx(long HInterID)
|
{
|
try
|
{
|
|
ds = oCN.RunProcReturn("select * from h_v_Gy_BarCodeBill_OutList where HMainID =" + HInterID, "h_v_Gy_BarCodeBill_OutList");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "false!";
|
objJsonResult.data = null;
|
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;
|
}
|
}
|
#endregion
|
|
#region [条码归档保存/编辑]
|
[Route("Gy_BarCodeBill_Out/ModifyByID")]
|
[HttpPost]
|
public object ModifyByID([FromBody] JObject oMain)
|
{
|
try
|
{
|
DAL.ClsGy_Employee_Ctl oDept = new DAL.ClsGy_Employee_Ctl();
|
DAL.ClsGy_Employee_View oDeptHlp = new DAL.ClsGy_Employee_View();
|
|
var _value = oMain["oMain"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();
|
//string msg3 = sArray[1].ToString();
|
//string msg4 = sArray[2].ToString();
|
//string msg5 = sArray[3].ToString();
|
|
//反序列化
|
msg2 = "[" + msg2.ToString() + "]";
|
List<Gy_BarCodeBill_Out> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_BarCodeBill_Out>>(msg2);
|
|
long HItemID = list[0].HItemID;
|
string HNumber = list[0].HNumber;
|
string HName = list[0].HName;
|
string HShortNumber = list[0].HNumber;
|
long HParentID = list[0].HParentID;
|
long HLevel = 1;
|
string HHelpCode = list[0].HHelpCode ?? "";
|
bool HEndFlag = list[0].HEndFlag;
|
long HStopflag = list[0].HStopflag;
|
string HRemark = list[0].HRemark;
|
string HUseFlag = list[0].HUseFlag ?? "";
|
|
long HInterID = list[0].HInterID; //主内码
|
long HEntryID = list[0].HEntryID; //子内码
|
string HBillType = list[0].HBillType; //类型
|
long HProcID = list[0].HProcID; //工序
|
string HBarCode = list[0].HBarCode;//(聚集索引) //条形码
|
string HBarCodeType = list[0].HBarCodeType; //条码类型(物料条码,箱号条码,托号条码)
|
long HItemSubID = list[0].HItemSubID; //对应核算项目
|
long HMaterID = list[0].HMaterID; //对应物料内码
|
long HUnitID = list[0].HUnitID; //计量单位
|
long HPieceQty = list[0].HPieceQty; //件数
|
decimal HQty = list[0].HQty; //数量
|
string HBatchNo = list[0].HBatchNo; //批次号
|
long HSupID = list[0].HSupID; //往来单位
|
long HGroupID = list[0].HGroupID; //生产班组(Gy_Group)
|
long HDeptID = list[0].HDeptID; //部门
|
long HEmpID = list[0].HEmpID; //业务员
|
string HMaker = list[0].HMaker; //制作人
|
string HMakeDate = list[0].HMakeDate; // 制作日期
|
long HPrintQty = list[0].HPrintQty; //打印次数
|
long HSourceInterID = list[0].HSourceInterID; //源单ID
|
long HSourceEntryID = list[0].HSourceEntryID; //源单子ID (如果有DETAILID 则填DETAILID)
|
string HSourceBillNo = list[0].HSourceBillNo; //源单单号
|
string HSourceBillType = list[0].HSourceBillType; //源单类型
|
string HEndQty = list[0].HEndQty; //尾箱数量
|
string HWei = list[0].HWei; //尾箱标记
|
string HBarCodeStatus = list[0].HBarCodeStatus; //条码状态
|
decimal HReadyQty = list[0].HReadyQty; //
|
decimal HInitQty = list[0].HInitQty; //初始化数量
|
long HBarcodeQtys = list[0].HBarcodeQtys; //总托数
|
long HBarcodeNo = list[0].HBarcodeNo; //当前托号
|
long HInstructID = list[0].HBarcodeNo; //
|
string HInstructNo = list[0].HInstructNo; //
|
long HSeOrderBillID = list[0].HSeOrderBillID; //销售订单内码
|
string HSeOrderBillNo = list[0].HSeOrderBillNo; //客户订单号
|
long HWhID = list[0].HWhID; //默认仓库
|
long HSPID = list[0].HSPID; //默认仓位
|
long HAuxPropID = list[0].HAuxPropID; //物料辅助属性
|
string HMaterName = list[0].HMaterName; //产品规格名称
|
string HMaterModel = list[0].HMaterModel; //产品规格型号
|
string HPinfan = list[0].HPinfan; //品番
|
string HMTONo = list[0].HMTONo; //MTO号
|
long HSupflag = list[0].HSupflag; //供应商标签标记
|
DateTime HBeginDate = list[0].HBeginDate; //开始日期
|
DateTime HEndDate = list[0].HEndDate; //结束日期
|
long HExpirationDateFlag = list[0].HExpirationDateFlag; //保质期标记
|
long HSourceID = list[0].HSourceID; //生产资源
|
string HCusType = list[0].HCusType; //
|
string HWorkLineName = list[0].HWorkLineName; //生产线
|
long HCusID = list[0].HCusID; //客户内码
|
long HSTOCKORGID = list[0].HSTOCKORGID; //库存组织
|
long HOWNERID = list[0].HOWNERID; //货主
|
string HJiaYe = list[0].HJiaYe; //加液代码
|
string HPressModel = list[0].HPressModel; //型号(韩电)
|
string HCusModel = list[0].HCusModel; //客户型号
|
string HMaterialModel = list[0].HMaterialModel; //产品规格
|
string HColor = list[0].HColor; //颜色
|
string HLogo = list[0].HLogo; //品牌
|
string HPackageSize = list[0].HPackageSize; //包装尺寸
|
decimal HMaterialJQty = list[0].HMaterialJQty; //净重
|
decimal HMaterialMQty = list[0].HMaterialMQty; //毛重
|
string HCustomBatchNo = list[0].HCustomBatchNo; //客户批次号
|
DateTime HBarCodeDate = list[0].HBarCodeDate; //条码标签日期
|
string HGBBarCode = list[0].HGBBarCode; //国标码
|
long HOldBarCodeFlag = list[0].HOldBarCodeFlag; //旧条码标记
|
long HOldSourceInterID = list[0].HOldSourceInterID; //老源单内码
|
long HOldSourceEntryID = list[0].HOldSourceEntryID; //老源单子内码
|
string HOldSourceBillNo = list[0].HOldSourceBillNo; //老源单单号
|
long HOrderInterID = list[0].HOrderInterID; //订单内码
|
long HOrderEntryID = list[0].HOrderEntryID; //订单子内码(如果有DETAILID 则填DETAILID)
|
string HOrderBillNo = list[0].HOrderBillNo; //订单单号
|
string HOrderBillType = list[0].HOrderBillType; //订单单据类型
|
string HRelationNum = list[0].HRelationNum;//对应编号
|
decimal HLabelQty = list[0].HLabelQty; //打印标签数量
|
decimal HMinQty = list[0].HMinQty; //最小包装数量
|
decimal HNowQty = list[0].HNowQty; //当前数量
|
string HStopMan = list[0].HStopMan; //禁用人
|
string HStopManDate = list[0].HStopManDate; //禁用日期
|
DateTime HInStockDate = list[0].HInStockDate;
|
DateTime HOutStockDate = list[0].HOutStockDate;
|
string HInStockDate_XF = list[0].HInStockDate_XF;
|
string HExpressNumber = list[0].HExpressNumber;
|
string POOrderBillNo = list[0].POOrderBillNo;
|
string HICMOReportBillNo = list[0].HICMOReportBillNo;
|
DateTime HICMOReportDate = list[0].HICMOReportDate;
|
long HInStockCounts = list[0].HInStockCounts;
|
long HReportCounts = list[0].HReportCounts;
|
long HOutStockCounts = list[0].HOutStockCounts;
|
string HInStockBillNo = list[0].HInStockBillNo;
|
string HOutStockBillNo = list[0].HOutStockBillNo;
|
string HSendGoodsBillNo = list[0].HSendGoodsBillNo;
|
string HKFDate = list[0].HKFDate;
|
long HKFPeriod = list[0].HKFPeriod;
|
string HKFDQDate = list[0].HKFDQDate;
|
long HServerItemID = list[0].HServerItemID;
|
string HBadReasonList = list[0].HBadReasonList;
|
string HProdLev = list[0].HProdLev;
|
long HSeOrderInterID = list[0].HSeOrderInterID;
|
long HSeOrderEntryID = list[0].HSeOrderEntryID;
|
string HInnerBillNo = list[0].HInnerBillNo;
|
string HCusBarCode = list[0].HCusBarCode;
|
string HStatus = list[0].HStatus;
|
long HInitSourceEntryID = list[0].HInitSourceEntryID;
|
string HOldSourceBillType = list[0].HOldSourceBillType;
|
decimal HMZ = list[0].HMZ;
|
long HGiveAwayFlag = list[0].HGiveAwayFlag; //赠品标记
|
long HSeOrderSEQ = list[0].HSeOrderSEQ;
|
long HMaterID_OLD = list[0].HMaterID_OLD;
|
string HDeleteMan = list[0].HDeleteMan;
|
DateTime HDeleteDate = list[0].HDeleteDate;
|
string HBarCode_Pack = list[0].HBarCode_Pack;
|
long HCustomQty1 = list[0].HCustomQty1;
|
DateTime HProduceDate = list[0].HProduceDate; //生产日期(保质期用)
|
DateTime HExpiryDate = list[0].HExpiryDate; //保质期至(保质期用)
|
|
//进行 会计期间 结账 的判断和控制
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = DateTime.Now;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.Message = s;
|
return objJsonResult;
|
}
|
|
////判断权限
|
//if (!ClsPub.Security_Log(msg5, 1, false, msg4))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "没有找到该功能模块!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
//if (!DBUtility.ClsPub.AllowNumber(HNumber))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "代码中不能出现连续‘.’并且首位末位不能为‘.’!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
//if (oDept.HavSameNumber(HItemID, HNumber))
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "代码重复!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
//保存
|
//保存完毕后处理
|
if (HItemID == 0)
|
{
|
oCN.BeginTran();
|
|
DateTime dt = DateTime.Now;
|
//42
|
oCN.RunProc(@"Insert into Gy_BarCodeBill_Out
|
(HInterID, HEntryID, HBillType, HProcID, HBarCode, HBarCodeType, HItemSubID, HMaterID, HUnitID,
|
HPieceQty, HQty, HBatchNo, HSupID, HGroupID, HDeptID, HEmpID, HMaker, HPrintQty, HSourceInterID, HSourceEntryID,
|
HSourceBillNo, HSourceBillType, HRemark, HUseFlag, HEndQty, HWei, HStopflag, HBarCodeStatus, HReadyQty, HInitQty,
|
HWhID, HSPID, HAuxPropID, HMTONo, HSupflag, HBeginDate, HEndDate, HExpirationDateFlag, HSourceID, HCusType,
|
HWorkLineName, HCusID, HSTOCKORGID, HOWNERID, HJiaYe, HPressModel, HCusModel, HMaterialModel, HColor, HLogo,
|
HPackageSize, HMaterialJQty, HMaterialMQty, HCustomBatchNo, HBarCodeDate, HGBBarCode, HOldBarCodeFlag, HOldSourceInterID,
|
HOldSourceEntryID, HOldSourceBillNo, HOrderInterID, HOrderEntryID, HOrderBillNo, HOrderBillType, HRelationNum,
|
HLabelQty, HMinQty, HNowQty, HStopMan, HInStockDate_XF, HExpressNumber, POOrderBillNo, HICMOReportBillNo, HInStockCounts,
|
HReportCounts, HOutStockCounts, HInStockBillNo, HOutStockBillNo, HSendGoodsBillNo, HServerItemID, HBadReasonList, HProdLev,
|
HInnerBillNo, HCusBarCode, HStatus, HInitSourceEntryID, HOldSourceBillType, HMZ, HGiveAwayFlag, HSeOrderSEQ, HMaterID_OLD,
|
HDeleteMan, HBarCode_Pack, HCustomQty1)
|
Values(" + 0 + "," + 0 + "," + 3330 + "," + HProcID + ",'" + HBarCode +
|
"','" + HBarCodeType + "'," + 0 + "," + HMaterID + "," + HUnitID + "," + HPieceQty +
|
"," + HQty + ",'" + HBatchNo + "'" + "," + HSupID + "," + HGroupID +
|
"," + HDeptID + "," + HEmpID + ",'" + HMaker + "'," + HPrintQty + "," + 0 +
|
"," + 0 + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HRemark + "'" +
|
",'" + HUseFlag + "','" + HEndQty + "','" + HWei + "'," + HStopflag + ",'" + HBarCodeStatus +
|
"'," + HReadyQty + "," + HInitQty + "," + HWhID + "," + HSPID + "," + HAuxPropID +
|
",'" + HMTONo + "'," + HSupflag + ",'" + dt + "','" + dt + "'," + HExpirationDateFlag +
|
"," + HSourceID + ",'" + HCusType + "','" + HWorkLineName + "'," + HCusID + "," + HSTOCKORGID +
|
"," + HOWNERID + ",'" + HJiaYe + "','" + HPressModel + "','" + HCusModel + "','" + HMaterialModel + "','" + HColor + "','" + HLogo + "'" +
|
",'" + HPackageSize + "'," + HMaterialJQty + "," + HMaterialMQty + ",'" + HCustomBatchNo + "','" + dt + "','" + HGBBarCode + "'" +
|
"," + HOldBarCodeFlag + "," + HOldSourceInterID + "," + HOldSourceEntryID + ",'" + HOldSourceBillNo + "'" +
|
"," + HOrderInterID + "," + HOrderEntryID + ",'" + HOrderBillNo + "','" + HOrderBillType +
|
"','" + HRelationNum + "'" + "," + HLabelQty + "," + HMinQty + "," + HNowQty + ",'" + HStopMan + "','" + dt +
|
"','" + HExpressNumber + "','" + POOrderBillNo + "','" + HICMOReportBillNo + "'," + HInStockCounts + "," + HReportCounts +
|
"," + HOutStockCounts + ",'" + HInStockBillNo + "','" + HOutStockBillNo + "','" + HSendGoodsBillNo +
|
"'," + HServerItemID + ",'" + HBadReasonList + "','" + HProdLev + "','" + HInnerBillNo + "','" + HCusBarCode + "','" + HStatus + "'," + HInitSourceEntryID + ",'" + HOldSourceBillType + "','" + HMZ + "'," + HGiveAwayFlag + "," + HSeOrderSEQ +
|
"," + HMaterID_OLD + ",'" + HDeleteMan + "','" + HBarCode_Pack + "'," + HCustomQty1 + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
|
//修改上级为非末级代码
|
oCN.RunProc("Update Gy_BarCodeBill_Out set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCN.Commit();
|
}
|
else
|
{
|
//若MAINDI重复则重新获取
|
oCN.BeginTran();
|
oCN.RunProc("Update Gy_BarCodeBill_Out set " +
|
" HBarCode='" + HBarCode + "'" +
|
",HProcID=" + HProcID +
|
",HBarCodeType='" + HBarCodeType + "'" +
|
",HMaterID=" + HMaterID +
|
",HUnitID=" + HUnitID +
|
|
",HPieceQty=" + HPieceQty +
|
",HQty=" + HQty +
|
",HBatchNo='" + HBatchNo + "'" +
|
",HSupID=" + HSupID +
|
",HGroupID=" + HGroupID +
|
",HDeptID=" + HDeptID +
|
",HEmpID=" + HEmpID +
|
",HEndQty=" + HEndQty +
|
",HWhID=" + HWhID +
|
",HSPID=" + HSPID +
|
",HAuxPropID=" + HAuxPropID +
|
",HCusID=" + HCusID +
|
",HSTOCKORGID=" + HSTOCKORGID +
|
//",HEndflag=" + Convert.ToString(HEndFlag ? 1 : 0) +
|
",HRemark= '" + HRemark.ToString() + "' Where HItemID=" + HItemID);
|
oCN.Commit();
|
}
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "保存成功!";
|
//WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
//oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region [删除]
|
[Route("Gy_BarCodeBill_Out/Delete")]
|
[HttpGet]
|
public object Delete(string HItemID, string user)
|
{
|
try
|
{
|
//进行 会计期间 结账 的判断和控制
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = DateTime.Now;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.Message = s;
|
return objJsonResult;
|
}
|
|
oCN.BeginTran();
|
oCN.RunProc("Delete From Gy_BarCodeBill_Out where HItemID = " + HItemID);
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "删除成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
}
|
}
|