| | |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Web; |
| | | using WebAPI.Dapper; |
| | | using WebAPI.Models; |
| | | using WebAPI.WebS; |
| | | |
| | |
| | | /// 获取单据号 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ApiResult<DocumentsView> GetInterBillNo() |
| | | public static ApiResult<DocumentsView> GetInterBillNo(string billType) |
| | | { |
| | | var hInterId= DBUtility.ClsPub.CreateBillID(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | var hBillNo= DBUtility.ClsPub.CreateBillCode(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | 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() |
| | |
| | | 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; |
| | | var result = oWebs.set_SaveStationInBill(oMain, ref sErrMsg); |
| | | if (!result) |
| | | if (dicLock.TryAdd(oMain.HICMOBillNo + "jz", ""))//防止并发 |
| | | return new ApiResult { code = -1, msg = "服务器繁忙" }; |
| | | try |
| | | { |
| | | if (oMain.HProcID == 0 || oMain.HQty == 0 || oMain.HEmpID == 0||string.IsNullOrEmpty(oMain.HICMOBillNo)||string.IsNullOrEmpty(oMain.HProcExchBillNo)||oMain.HQty==0||oMain.HICMOInterID==0||string.IsNullOrEmpty(oMain.HBillNo)) |
| | | return new ApiResult { code = 1, msg = "参数不全" }; |
| | | var stationInList = YqnDal.GetStationInBillMailList(oMain.HICMOBillNo);//获得该流转卡所有进站单 |
| | | if (stationInList.Count > 0) |
| | | { |
| | | var stationOutList = YqnDal.GetStationOutBillMailList(oMain.HICMOBillNo);//获得该流转卡所有出站单 |
| | | var stationInModel = stationInList.OrderByDescending(a => a.HDate).First();//获取进站单最新进站工序 |
| | | if (stationOutList.Count == 0 && oMain.HEmpID == stationInModel.HEmpID) |
| | | return new ApiResult { code = -1, msg = "重复扫描" }; |
| | | if (stationOutList.Count == 0 && oMain.HEmpID != stationInModel.HEmpID) |
| | | return new ApiResult { code = -1, msg = "此单已关联" }; |
| | | var stationOutModel = stationOutList.OrderByDescending(a => a.HDate).First();//获取出站单最新出站工序 |
| | | if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HEmpID == oMain.HEmpID) |
| | | return new ApiResult { code = -1, msg = "重复扫描" }; |
| | | if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HEmpID == oMain.HEmpID) |
| | | 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 = sErrMsg }; |
| | | } |
| | | return new ApiResult { code = 1, msg = "操作成功" }; |
| | | } |
| | | return new ApiResult { code = 1, msg = "操作成功" }; |
| | | catch (Exception ex) |
| | | { |
| | | throw; |
| | | } |
| | | finally |
| | | { |
| | | dicLock.TryRemove(oMain.HICMOBillNo + "jz", out string key); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 获取进站单列表 |
| | |
| | | /// </summary> |
| | | public static ApiResult SetStationOutBill(StationOutBillView omodel) |
| | | { |
| | | if (!dicLock.TryAdd(omodel.HBillNo, omodel.HBillNo)) |
| | | return new ApiResult { code = -1, msg = "服务器繁忙" }; |
| | | var stationInBillModel = YqnDal.GetStationInBillMail(omodel.HProcID, omodel.HICMOBillNo); |
| | | if (stationInBillModel == null) |
| | | return new ApiResult { code = -1, msg = "该工序进站单不存在" }; |
| | | var stationOutBillModel = YqnDal.GetStationOutBillMail(omodel.HProcID, omodel.HICMOBillNo); |
| | | if (stationOutBillModel != null) |
| | | return new ApiResult { code = -1, msg = "该工序已存在出站单" }; |
| | | WebS.WebService1 oWebs = new WebS.WebService1(); |
| | | string sErrMsg = string.Empty; |
| | | var result = SetOutBill(omodel); |
| | |
| | | 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 " + |
| | | oCN.RunProc("Insert Into Sc_StationOutBillMain " + |
| | | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" + |
| | | ",HYear,HPeriod,HRemark" + |
| | | ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + |
| | |
| | | ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + |
| | | ",HSupID,HQty,HPrice,HMoney" + |
| | | ") " + |
| | | " values('4788','4788'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + ",getdate(),'" + DBUtility.ClsPub.CurUserName + "',getdate()" + |
| | | " 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() + |
| | | ") "; |
| | | oCN.RunProc(sql); |
| | | ") "); |
| | | oCN.Commit(); |
| | | return new ApiResult { code = 1, msg = "新增成功" }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return new ApiResult { code = -1, msg = "保存错误/"+ex.ToString() }; |
| | | } |
| | | finally |
| | | { |
| | | dicLock.TryRemove(omodel.HBillNo, out string key); |
| | | } |
| | | } |
| | | public static ApiResult SetInBill(ClsSc_StationInBillMain omodel) |