| | |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Web; |
| | | using WebAPI.Dapper; |
| | | using WebAPI.Models; |
| | |
| | | { |
| | | var stationOutList = YqnDal.GetStationOutBillMailList(oMain.HICMOBillNo);//获得该流转卡所有出站单 |
| | | var stationInModel = stationInList.OrderByDescending(a => a.HDate).First();//获取进站单最新进站工序 |
| | | if (stationOutList.Count == 0 && oMain.HEmpID == stationInModel.HEmpID) |
| | | if (stationOutList.Count == 0 && oMain.HProcID == stationInModel.HProcID) |
| | | return new ApiResult { code = -1, msg = "重复扫描" }; |
| | | if (stationOutList.Count == 0 && oMain.HEmpID != stationInModel.HEmpID) |
| | | 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.HEmpID == oMain.HEmpID) |
| | | if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HProcID == oMain.HProcID) |
| | | return new ApiResult { code = -1, msg = "重复扫描" }; |
| | | if (stationInModel.HProcID != stationOutModel.HProcID && stationInModel.HEmpID == oMain.HEmpID) |
| | | 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 = "该单据已完成此工艺" }; |
| | |
| | | var result = oWebs.set_SaveStationInBill(oMain, ref sErrMsg);//进站 |
| | | if (!result) |
| | | { |
| | | |
| | | return new ApiResult { code = -1, msg = sErrMsg }; |
| | | } |
| | | return new ApiResult { code = 1, msg = "操作成功" }; |
| | |
| | | /// </summary> |
| | | public static ApiResult SetStationOutBill(StationOutBillView omodel) |
| | | { |
| | | if (!dicLock.TryAdd(omodel.HBillNo, omodel.HBillNo)) |
| | | if (!dicLock.TryAdd(omodel.HBillNo, omodel.HBillNo))//同一单号并发处理 |
| | | return new ApiResult { code = -1, msg = "服务器繁忙" }; |
| | | var stationInBillModel = YqnDal.GetStationInBillMail(omodel.HProcID, omodel.HICMOBillNo); |
| | | if (stationInBillModel == null) |
| | |
| | | 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; |
| | | omodel.HYear = DateTime.Now.Year; |
| | | var result = SetOutBill(omodel); |
| | | return result; |
| | | } |
| | |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | omodel.HInterID = DBUtility.ClsPub.CreateBillID("3791", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | oCN.BeginTran(); |
| | | oCN.RunProc("Insert Into Sc_StationOutBillMain " + |
| | | //oCN.BeginTran(); |
| | | var sql = "Insert Into Sc_StationOutBillMain " + |
| | | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" + |
| | | ",HYear,HPeriod,HRemark" + |
| | | ",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 = "新增成功" }; |
| | | } |
| | |
| | | } |
| | | public static ApiResult SetInBill(ClsSc_StationInBillMain omodel) |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | try |
| | | { |
| | | var nowTime = DateTime.Now; |
| | | omodel.HBillType = "3790"; |
| | | omodel.HYear = nowTime.Year; |
| | | omodel.HBillSubType = "3790"; |
| | | //得到mainid |
| | | omodel.HInterID = DBUtility.ClsPub.CreateBillID("3790", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | 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(); |
| | | //主表 |
| | | oCN.RunProc("Insert Into Sc_StationInBillMain " + |
| | | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" + |
| | | ",HYear,HPeriod,HRemark" + |
| | | ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + |
| | | ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID" + |
| | | ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + |
| | | ",HSupID,HQty,HPrice,HMoney,HMaker" + |
| | | ") " + |
| | | " values('3790','3790'," + 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.HMaker+"') "); |
| | | |
| | | oCN.Commit(); |
| | | //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(); |
| | | //oCN.RollBack(); |
| | | return new ApiResult { code = -1, msg = "保存错误/" + e.ToString() }; |
| | | } |
| | | } |