| | |
| | | |
| | | #endregion |
| | | |
| | | #region 下模单 PDA新增 |
| | | /// <summary> |
| | | /// 新增单据-保存按钮 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | #region 下模单 PDA新增 新的260227 app在发信息的时候回放到事务外 |
| | | [Route("Sc_MouldUpperBill/AddSc_MouldLowerBill_PDA")] |
| | | [HttpPost] |
| | | public object AddSc_MouldLowerBill_PDA([FromBody] JObject oMain) |
| | | { |
| | | var _value = oMain["oMain"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); // 用户名 |
| | | int OperationType = int.Parse(sArray[2].ToString()); // 数据类型 1添加 3修改 2复制 |
| | | |
| | | // 开始事务 |
| | | oCN.BeginTran(); |
| | | |
| | | try |
| | | { |
| | | // 权限校验 |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Edit", 1, false, user)) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限编辑!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 处理主表 JSON(包装成数组形式) |
| | | string mainJsonArray = "[" + msg2 + "]"; |
| | | List<ClsSc_MouldLowerBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillMain>>(mainJsonArray); |
| | | string HBillType = "3847"; |
| | | long HInterID = mainList[0].HInterID; |
| | | string HBillNo = mainList[0].HBillNo; |
| | | DateTime HDate = mainList[0].HDate; |
| | | int HYear = DateTime.Now.Year; |
| | | double HPeriod = DateTime.Now.Month; |
| | | string HRemark = mainList[0].HRemark; |
| | | string HMaker = mainList[0].HMaker; |
| | | int HOrgID = mainList[0].HOrgID; |
| | | Int64 HDeptID = mainList[0].HDeptID; |
| | | Int64 HEmpID = mainList[0].HEmpID; |
| | | Int64 HMangerID = mainList[0].HMangerID; |
| | | |
| | | // 查询主表是否存在(用于判断新增/修改) |
| | | ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldLowerBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Qj_Sc_MouldLowerBillList"); |
| | | |
| | | // ----- 主表保存逻辑 ----- |
| | | if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0) // 新增 |
| | | { |
| | | // 保存前控制 |
| | | objJsonResult = BeforeSave_MouldLowerBill(HInterID, HBillNo, 1); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 插入主表 |
| | | oCN.RunProc(@"Insert Into Sc_MouldLowerBillMain |
| | | (HBillType, HBillStatus, HBillSubType, HInterID, HBillNo, HDate |
| | | , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID |
| | | , HDeptID, HEmpID, HMangerID) values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" |
| | | + "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID |
| | | + "," + HDeptID + "," + HEmpID + "," + HMangerID + ") "); |
| | | } |
| | | else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) // 修改或已存在 |
| | | { |
| | | // 保存前控制 |
| | | objJsonResult = BeforeSave_MouldLowerBill(HInterID, HBillNo, 2); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 更新主表 |
| | | oCN.RunProc("update Sc_MouldLowerBillMain set " + |
| | | "HDate='" + HDate + |
| | | "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + |
| | | "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + |
| | | " where HInterID='" + HInterID + "'"); |
| | | |
| | | // 删除原有子表(修改时重新插入) |
| | | oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID='" + HInterID + "'"); |
| | | } |
| | | |
| | | // ----- 子表保存逻辑 ----- |
| | | List<ClsSc_MouldLowerBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillSub>>(mainJsonArray); |
| | | int i = 0; |
| | | foreach (ClsSc_MouldLowerBillSub oSub in DetailColl) |
| | | { |
| | | i++; |
| | | oCN.RunProc(@"Insert Into Sc_MouldLowerBillSub |
| | | (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty |
| | | , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo |
| | | , HProcExchBillNo, HProcExchInterID, HProcExchEntryID |
| | | , HScanDate, HBarCode) |
| | | values(" |
| | | + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty |
| | | + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString() |
| | | + "','" + oSub.HProcExchBillNo.ToString() + "'," + oSub.HProcExchInterID.ToString() + "," + oSub.HProcExchEntryID.ToString() |
| | | + ",'" + oSub.HScanDate.ToString() + "','" + oSub.HMouldNumber.ToString() + "') "); |
| | | } |
| | | |
| | | // 保存后控制(根据操作类型) |
| | | if (OperationType == 1) // 新增 |
| | | { |
| | | objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 1); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else // 修改/复制 |
| | | { |
| | | objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 2); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | // 所有操作成功,提交事务 |
| | | oCN.Commit(); |
| | | |
| | | if (OperationType == 1) // 新增 |
| | | { |
| | | // 自动生成工作联系单(华舟专用) |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "华舟") |
| | | { |
| | | var ds2 = oCN.RunProcReturn("exec h_p_OA_WorkLinkBill_Create " + HInterID + "," + 3847, "h_p_OA_WorkLinkBill_Create"); |
| | | if (ds2 != null && ds2.Tables[0].Rows.Count > 0) |
| | | { |
| | | int HInterID0 = int.Parse(ds2.Tables[0].Rows[0]["NewHInterID"].ToString()); |
| | | LogService.Write("执行消息推送..." + HInterID0); |
| | | Service.GeTuiService.PubishSingle(HInterID0); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 返回成功结果(注意原逻辑中使用了 ds.Tables[0]) |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "新增单据成功!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 下模单 PDA新增 老的 老的app在发信息的时候回导致表被锁住 |
| | | [Route("Sc_MouldUpperBill/AddSc_MouldLowerBill_PDA_OLD")] |
| | | [HttpPost] |
| | | public object AddSc_MouldLowerBill_PDA_OLD([FromBody] JObject oMain) |
| | | { |
| | | var _value = oMain["oMain"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | |
| | | LogService.Write("执行消息推送..." + HInterID0); |
| | | |
| | | // 触发消息推送 |
| | | Service.GeTuiService.PubishSingle(HInterID0); |
| | | //Service.GeTuiService.PubishSingle(HInterID0); |
| | | |
| | | } |
| | | } |