|  |  |  | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using System.Data; | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Web; | 
|---|
|  |  |  | using WebAPI.Dapper; | 
|---|
|  |  |  | using WebAPI.Models; | 
|---|
|  |  |  | using WebAPI.WebS; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /// 获取单据号 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public static ApiResult<DocumentsView> GetInterBillNo() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var hInterId= DBUtility.ClsPub.CreateBillID(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | var hBillNo= DBUtility.ClsPub.CreateBillCode(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); | 
|---|
|  |  |  | public static ApiResult<DocumentsView> GetInterBillNo(string billType) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var hInterId = DBUtility.ClsPub.CreateBillID(billType, ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | var hBillNo = DBUtility.ClsPub.CreateBillCode(billType, ref DBUtility.ClsPub.sExeReturnInfo, true); | 
|---|
|  |  |  | if (hInterId == 0 || string.IsNullOrEmpty(hBillNo)) | 
|---|
|  |  |  | return new ApiResult<DocumentsView> { code = -1, msg = "获取失败" }; | 
|---|
|  |  |  | DocumentsView documentsView = new DocumentsView() | 
|---|
|  |  |  | 
|---|
|  |  |  | var dataSet = GetBarCodeDb(sBillBarCode); | 
|---|
|  |  |  | if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "不存在流转卡号" }; | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = 1, msg = "查询成功",data=dataSet }; | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 流转卡回车方法 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public static ApiResult<DataSet> GetProcDetail(string sBillNo, string sProcNo) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (string.IsNullOrEmpty(sBillNo)||string.IsNullOrEmpty(sProcNo)) | 
|---|
|  |  |  | if (string.IsNullOrEmpty(sBillNo) || string.IsNullOrEmpty(sProcNo)) | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "条码和流转卡不能为空" }; | 
|---|
|  |  |  | var dataSet = GetProcDb(sBillNo, sProcNo); | 
|---|
|  |  |  | if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "未查询到工作中心" }; | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private static ConcurrentDictionary<string, string> dicLock = new System.Collections.Concurrent.ConcurrentDictionary<string, string>();//并发锁 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 进站接收单 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public static ApiResult SetStationInBill(ClsSc_StationInBillMain oMain) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WebS.WebService1 oWebs = new WebS.WebService1(); | 
|---|
|  |  |  | string sErrMsg = string.Empty; | 
|---|
|  |  |  | oMain.HYear = 2021; | 
|---|
|  |  |  | oMain.HPeriod = 1; | 
|---|
|  |  |  | var result = oWebs.set_SaveStationInBill(oMain, ref  sErrMsg); | 
|---|
|  |  |  | if (!result) | 
|---|
|  |  |  | if (!dicLock.TryAdd(oMain.HICMOBillNo + "jz", ""))//防止并发 | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "服务器繁忙" }; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = sErrMsg }; | 
|---|
|  |  |  | if (oMain.HProcID == 0 || oMain.HQty == 0 || string.IsNullOrEmpty(oMain.HProcExchBillNo) || oMain.HQty == 0 || string.IsNullOrEmpty(oMain.HBillNo)) | 
|---|
|  |  |  | return new ApiResult { code = 1, msg = "参数不全" }; | 
|---|
|  |  |  | var stationInList = YqnDal.GetStationInBillMailList(oMain.HProcExchBillNo);//获得该流转卡所有进站单 | 
|---|
|  |  |  | if (stationInList.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var stationOutList = YqnDal.GetStationOutBillMailList(oMain.HProcExchBillNo);//获得该流转卡所有出站单 | 
|---|
|  |  |  | var stationInModel = stationInList.OrderByDescending(a => a.HDate).First();//获取进站单最新进站工序 | 
|---|
|  |  |  | if (stationOutList.Count == 0 && oMain.HProcID == stationInModel.HProcID) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "重复扫描" }; | 
|---|
|  |  |  | if (stationOutList.Count == 0 && oMain.HProcID != stationInModel.HProcID) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "此单已关联" }; | 
|---|
|  |  |  | var stationOutModel = stationOutList.OrderByDescending(a => a.HDate).First();//获取出站单最新出站工序 | 
|---|
|  |  |  | if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HProcID == oMain.HProcID) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "重复扫描" }; | 
|---|
|  |  |  | if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HProcID == oMain.HProcID) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "此单已关联" }; | 
|---|
|  |  |  | if (stationOutList.Exists(a => a.HProcID == oMain.HProcID)) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "该单据已完成此工艺" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WebS.WebService1 oWebs = new WebS.WebService1(); | 
|---|
|  |  |  | string sErrMsg = string.Empty; | 
|---|
|  |  |  | var result = oWebs.set_SaveStationInBill(oMain, ref sErrMsg);//进站 | 
|---|
|  |  |  | if (!result) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = sErrMsg }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new ApiResult { code = 1, msg = "操作成功" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new ApiResult { code = 1, msg = "操作成功" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 出站接收单 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public static ApiResult SetStationOutBill(StationOutBillView omodel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WebS.WebService1 oWebs = new WebS.WebService1(); | 
|---|
|  |  |  | omodel.HYear = 2021; | 
|---|
|  |  |  | omodel.HPeriod = 1; | 
|---|
|  |  |  | string sErrMsg = string.Empty; | 
|---|
|  |  |  | var result = SetOutBill(omodel); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "请求错误" + ex.ToString() }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | finally | 
|---|
|  |  |  | { | 
|---|
|  |  |  | dicLock.TryRemove(oMain.HICMOBillNo + "jz", out string key); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 获取进站单列表 | 
|---|
|  |  |  | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "未查询到数据" }; | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 获取流转卡列表 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="sWhere"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public static ApiResult<DataSet> GetPorcessMainList(string sWhere) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var dataSet = GetProcessMain(sWhere); | 
|---|
|  |  |  | if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "未查询到数据" }; | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 获取流转卡子表列表 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="sWhere"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public static ApiResult<DataSet> GetPorcessSubList(int hInterId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var dataSet = GetProcessSubList(hInterId); | 
|---|
|  |  |  | if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = -1, msg = "未查询到数据" }; | 
|---|
|  |  |  | return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 出站接收单 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public static ApiResult SetStationOutBill(StationOutBillView omodel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!dicLock.TryAdd(omodel.HICMOBillNo + "cz", omodel.HBillNo))//同一单号并发处理 | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "服务器繁忙" }; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var stationInBillModel = YqnDal.GetStationInBillMail(omodel.HProcID, omodel.HProcExchBillNo); | 
|---|
|  |  |  | if (stationInBillModel == null) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "该工序进站单不存在" }; | 
|---|
|  |  |  | var stationOutBillModel = YqnDal.GetStationOutBillMail(omodel.HProcID, omodel.HProcExchBillNo); | 
|---|
|  |  |  | if (stationOutBillModel != null) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "该工序已存在出站单" }; | 
|---|
|  |  |  | omodel.HYear = DateTime.Now.Year; | 
|---|
|  |  |  | var result = SetOutBill(omodel); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = ex.ToString() }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | finally | 
|---|
|  |  |  | { | 
|---|
|  |  |  | dicLock.TryRemove(omodel.HICMOBillNo + "cz", out string key); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 获取工序详情 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="hItemId"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public static ApiResult<Models.M_Process> GetProcessDetail(int hItemId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var processModel = ProcessDal.GetProcessDetail(hItemId); | 
|---|
|  |  |  | if (processModel == null) | 
|---|
|  |  |  | return new ApiResult<M_Process> { code = -1, msg = "查询为空" }; | 
|---|
|  |  |  | processModel.DepartmentModel = ProcessDal.GetDepartmentModel(processModel.HDeptID); | 
|---|
|  |  |  | processModel.ProcMulModel = ProcessDal.GetProcMulModel(processModel.HProcMulID); | 
|---|
|  |  |  | return new ApiResult<M_Process> { code = 1, msg = "查询成功", data = processModel }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 获取工序列表 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="hName"></param> | 
|---|
|  |  |  | /// <param name="hLevel"></param> | 
|---|
|  |  |  | /// <param name="hNumber"></param> | 
|---|
|  |  |  | /// <param name="hBillSubType"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public static ApiResult<List<Models.M_Process>> GetProcessList(string hName, int hLevel, string hNumber, string hBillSubType, int page, int limit) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | int pageCount = 0; | 
|---|
|  |  |  | var list = ProcessDal.GetProcessList(hName, hLevel, hNumber, hBillSubType, page, limit, ref pageCount); | 
|---|
|  |  |  | if (list?.Count == 0) | 
|---|
|  |  |  | return new ApiResult<List<M_Process>> { code = -1, msg = "查询为空" }; | 
|---|
|  |  |  | return new ApiResult<List<M_Process>> { code = 0, msg = "查询成功", data = list, count = pageCount }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 删除一条工序 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="hItemID"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public static ApiResult DeleteProcess(int hItemID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var result = ProcessDal.DeleteProcess(hItemID); | 
|---|
|  |  |  | if (result > 0) | 
|---|
|  |  |  | return new ApiResult { code = 1, msg = "删除成功" }; | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "删除数据不存在" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #region sql语句 | 
|---|
|  |  |  | public static DataSet GetStationOutBill(string strWhere) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var sql = "Select top 5000 * from h_v_MES_StationInBillList Where 1=1 " + strWhere; | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | var dataSet= oCN.RunProcReturn(sql, "h_v_MES_StationInBillList"); | 
|---|
|  |  |  | var dataSet = oCN.RunProcReturn(sql, "h_v_MES_StationInBillList"); | 
|---|
|  |  |  | return dataSet; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static DataSet GetProcessSubList(int hInterId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var sql = "select a.HProcNo 流水号,a.HProcNumber as 工序代码,b.HName 工序名称,c.HName 工作中心,a.HQty 流转卡数量 from Sc_ProcessExchangeBillSub a left join Gy_Process b on b.HItemID = a.HProcID left join Gy_WorkCenter c on c.HItemID = a.HCenterID where 1=1 and a.HInterID=" + hInterId; | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | var dataSet = oCN.RunProcReturn(sql, "Sc_ProcessExchangeBillSub"); | 
|---|
|  |  |  | return dataSet; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static DataSet GetProcessMain(string strWhere) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var sql = "select a.HBillNo 单据号, a.HDate 日期, HInterID, a.HICMOBillNo 生产订单, b.HName 产品名称, b.HNumber 产品代码, a.HPlanQty 流转卡数量, c.HName 单位, a.HPlanBeginDate 计划开工日期, a.HPlanEndDate 计划完工日期, a.HRemark 备注" + | 
|---|
|  |  |  | " from Sc_ProcessExchangeBillMain a left join Gy_Material b on a.HMaterID = b.HItemID left join Gy_Unit c on c.HItemID = a.HUnitID where 1=1 " + strWhere; | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | var dataSet = oCN.RunProcReturn(sql, "Sc_ProcessExchangeBillMain"); | 
|---|
|  |  |  | return dataSet; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static DataSet GetBarCodeDb(string billBarCode) | 
|---|
|  |  |  | 
|---|
|  |  |  | var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 工作中心代码,HName 工作中心 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source"); | 
|---|
|  |  |  | return dataSet; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private static ConcurrentDictionary<string,string> dicLock=new System.Collections.Concurrent.ConcurrentDictionary<string,string>();//并发锁 | 
|---|
|  |  |  | public static ApiResult SetOutBill(StationOutBillView omodel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!dicLock.TryAdd(omodel.HBillNo, omodel.HBillNo)) | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "服务器繁忙" }; | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | omodel.HInterID = DBUtility.ClsPub.CreateBillID("4788", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | omodel.HInterID = DBUtility.ClsPub.CreateBillID("3791", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | var sql = "Insert Into Sc_StationOutBillMain " + | 
|---|
|  |  |  | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" + | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + | 
|---|
|  |  |  | ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID" + | 
|---|
|  |  |  | ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + | 
|---|
|  |  |  | ",HSupID,HQty,HPrice,HMoney" + | 
|---|
|  |  |  | ",HSupID,HQty,HPrice,HMoney,HProcNo" + | 
|---|
|  |  |  | ") " + | 
|---|
|  |  |  | " values('3791','3791'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + ",getdate(),'" + DBUtility.ClsPub.CurUserName + "',getdate()" + | 
|---|
|  |  |  | "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "'" + | 
|---|
|  |  |  | "," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "'," + omodel.HProcPlanInterID.ToString() + "," + omodel.HProcPlanEntryID.ToString() + ",'" + omodel.HProcPlanBillNo + "'," + omodel.HProcExchInterID.ToString() + "," + omodel.HProcExchEntryID.ToString() + | 
|---|
|  |  |  | ",'" + omodel.HProcExchBillNo + "'," + omodel.HMaterID.ToString() + "," + omodel.HProcID.ToString() + "," + omodel.HICMOQty.ToString() + "," + omodel.HPlanQty.ToString() + ",getdate()," + omodel.HSourceID.ToString() + | 
|---|
|  |  |  | "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HBarCodeMaker + "',getdate()" + | 
|---|
|  |  |  | "," + omodel.HSupID.ToString() + "," + omodel.HQty.ToString() + "," + omodel.HPrice.ToString() + "," + omodel.HMoney.ToString() + | 
|---|
|  |  |  | ") "; | 
|---|
|  |  |  | "," + omodel.HSupID.ToString() + "," + omodel.HQty.ToString() + "," + omodel.HPrice.ToString() + "," + omodel.HMoney.ToString() + "," + omodel.HProcNo + ") "; | 
|---|
|  |  |  | //var result= SqlPools.GetInstance("YqnConn").ExecuteCommand(sql); | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  | oCN.Commit(); | 
|---|
|  |  |  | return new ApiResult { code = 1, msg = "新增成功" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "保存错误/"+ex.ToString() }; | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "保存错误/" + ex.ToString() }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | finally | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static ApiResult SetInBill(ClsSc_StationInBillMain omodel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | dicLock.TryRemove(omodel.HBillNo, out string key); | 
|---|
|  |  |  | var nowTime = DateTime.Now; | 
|---|
|  |  |  | omodel.HBillType = "3790"; | 
|---|
|  |  |  | omodel.HYear = nowTime.Year; | 
|---|
|  |  |  | omodel.HBillSubType = "3790"; | 
|---|
|  |  |  | //得到mainid | 
|---|
|  |  |  | omodel.HInterID = DBUtility.ClsPub.CreateBillID(omodel.HBillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | omodel.HDate = nowTime; | 
|---|
|  |  |  | omodel.HMakeDate = nowTime.ToString(); | 
|---|
|  |  |  | omodel.HStationInTime = nowTime; | 
|---|
|  |  |  | omodel.HBarCodeMakeDate = nowTime; | 
|---|
|  |  |  | omodel.HPeriod = 1; | 
|---|
|  |  |  | var sqlBuilder = new StringBuilder(); | 
|---|
|  |  |  | sqlBuilder.Append("Insert Into Sc_StationInBillMain(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HYear,HPeriod,HRemark,HICMOInterID,HICMOBillNo"); | 
|---|
|  |  |  | sqlBuilder.Append(",HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID"); | 
|---|
|  |  |  | sqlBuilder.Append(",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSupID,HQty,HPrice,HMoney,HProcId,HProcNo) values "); | 
|---|
|  |  |  | sqlBuilder.Append("(@HBillType,@HBillSubType,@HInterID,@HBillNo,@HBillStatus,@HDate,@HMaker,@HMakeDate,@HYear,@HPeriod,@HRemark,@HICMOInterID,@HICMOBillNo"); | 
|---|
|  |  |  | sqlBuilder.Append(",@HProcPlanInterID,@HProcPlanEntryID,@HProcPlanBillNo,@HProcExchInterID,@HProcExchEntryID,@HProcExchBillNo,@HMaterID,@HProcID,@HICMOQty,@HPlanQty,@HStationInTime,@HSourceID"); | 
|---|
|  |  |  | sqlBuilder.Append(",@HGroupID,@HDeptID,@HEmpID,@HBarCode,@HAddr,@HBarCodeMaker,@HBarCodeMakeDate,@HSupID,@HQty,@HPrice,@HMoney,@HProcId,@HProcNo)"); | 
|---|
|  |  |  | //若MAINDI重复则重新获取 | 
|---|
|  |  |  | //oCN.BeginTran(); | 
|---|
|  |  |  | var result = SqlPools.GetInstance("YqnConn").ExecuteCommand(sqlBuilder.ToString(), omodel); | 
|---|
|  |  |  | //oCN.RunProc(sql); | 
|---|
|  |  |  | //oCN.Commit(); | 
|---|
|  |  |  | return new ApiResult { code = 1, msg = "新增成功" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //oCN.RollBack(); | 
|---|
|  |  |  | return new ApiResult { code = -1, msg = "保存错误/" + e.ToString() }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|