New file |
| | |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Pub_Class; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | | public class Sc_KeyElementBindingController : ApiController |
| | | { |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | |
| | | #region å·¥åºæµè½¬å¡ç»´æ¤-æ¥è¯¢ |
| | | /// <summary> |
| | | /// è¿åå·¥åºæµè½¬å¡ç»´æ¤å表主表 |
| | | ///åæ°ï¼string sqlã |
| | | ///è¿åå¼ï¼objectã |
| | | /// </summary> |
| | | [Route("Sc_KeyElementBinding/GetProcessExchangeList")] |
| | | [HttpGet] |
| | | public object GetProcessExchangeList(string HBillNo, string user) |
| | | { |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeInfo_ForKeyBind where æµè½¬å¡å· = '" + HBillNo + "'", "h_v_Sc_ProcessExchangeInfo_ForKeyBind"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0 && ds != null) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¥æ æ¤æµè½¬å¡ä¿¡æ¯ï¼è¯·æ ¸å¯¹æ¹æµè½¬å¡æ¯å¦å·²è¢«å é¤"; |
| | | objJsonResult.data = ""; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å¼å¸¸ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region å
³é®ä»¶ç»å® äº§åæ¡ç è§£æ |
| | | [Route("Sc_KeyElementBinding/ProductBardCode_JX")] |
| | | [HttpGet] |
| | | public object ProductBardCode_JX(string HBarCode, string HProcExchBillNo, string HBillNo, string user, int HOrgID) |
| | | { |
| | | try |
| | | { |
| | | //å¤æææ«æ¡ç æ¯å¦å卿¡ç æ¡£æ¡å½ä¸ |
| | | ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | //æ¡ç æ¡£æ¡ä¸æ²¡ææ¬æ¬¡æ«æçæ¡ç ï¼åæ ¹æ®è§åè§£æçææ¡ç |
| | | ds = oCN.RunProcReturn(@"exec h_p_Sc_BarCode_JX '" + HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'", "h_p_Sc_BarCode_JX"); |
| | | |
| | | if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "è§£ææ¡ç 失败ï¼è¯·ä¸ç®¡çèç³»ï¼" + ds.Tables[0].Rows[0]["HBackRemark"] + "==exec h_p_Sc_BarCode_JX '" +HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'"; |
| | | objJsonResult.data = ""; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //æ¡ç æ¡£æ¡ä¸å·²ææ¬æ¬¡æ«æçæ¡ç ï¼å¹é
ç¨ææ¸
åï¼æ«ç æ°æ®åå
¥ä¸´æ¶è¡¨ï¼ |
| | | ds = oCN.RunProcReturn(@"exec h_p_Sc_PPBomBill_Matching '" + HBarCode + "','" + HProcExchBillNo + "','" + HBillNo + "','" + HOrgID + "'", "h_p_Sc_PPBomBill_Matching"); |
| | | if (ds != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); |
| | | objJsonResult.data = ""; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = ""; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = ""; |
| | | objJsonResult.data = "æ²¡ææ¥è¯¢å°æ°æ®"; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ERRORï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region å
³é®ä»¶ç»å® é
ä»¶æ¡ç è§£æ |
| | | [Route("Sc_KeyElementBinding/PartsBardCode_JX")] |
| | | [HttpGet] |
| | | public object PartsBardCode_JX(string HBarCode, string HProcExchBillNo, string HBillNo, string user, int HOrgID) |
| | | { |
| | | try |
| | | { |
| | | //å¤æææ«æ¡ç æ¯å¦å卿¡ç æ¡£æ¡å½ä¸ |
| | | ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | //æ¡ç æ¡£æ¡ä¸æ²¡ææ¬æ¬¡æ«æçæ¡ç ï¼åæ ¹æ®è§åè§£æçææ¡ç |
| | | ds = oCN.RunProcReturn(@"exec h_p_Sc_BarCode_JX '" + HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'", "h_p_Sc_BarCode_JX"); |
| | | if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "è§£ææ¡ç 失败ï¼è¯·ä¸ç®¡çèç³»ï¼" + ds.Tables[0].Rows[0]["HBackRemark"] + "==exec h_p_Sc_BarCode_JX '" + HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'"; |
| | | objJsonResult.data = ""; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //æ¡ç æ¡£æ¡ä¸å·²ææ¬æ¬¡æ«æçæ¡ç ï¼æ¥è¯¢é
ä»¶ä¿¡æ¯ï¼æ«ææ¡ç ä¿¡æ¯åå
¥ä¸´æ¶è¡¨ï¼ |
| | | ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBill_Bind '" + HBarCode + "','" + HProcExchBillNo + "','" + HBillNo + "','" + HOrgID + "'", "h_p_Gy_BarCodeBill_Bind"); |
| | | |
| | | if (ds != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); |
| | | objJsonResult.data = ""; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = ""; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = ""; |
| | | objJsonResult.data = "æ²¡ææ¥è¯¢å°æ°æ®"; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ERRORï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region å
³é®ä»¶ç»å®ä¿å æ°å¢/ç¼è¾ |
| | | [Route("Sc_KeyElementBinding/Save")] |
| | | [HttpPost] |
| | | public object Save([FromBody] JObject msg) |
| | | { |
| | | var _value = msg["msg"].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(); //ç¨æ· |
| | | |
| | | DBUtility.ClsPub.CurUserName = msg4; |
| | | |
| | | string UserName = ""; |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | |
| | | |
| | | DAL.ClsSc_AssemblyBill oBill = new DAL.ClsSc_AssemblyBill(); |
| | | List<Model.ClsSc_AssemblyBillMain> lsmain = new List<Model.ClsSc_AssemblyBillMain>(); |
| | | msg2 = msg2.Replace("\\", ""); |
| | | msg2 = msg2.Replace("\n", ""); //\n |
| | | lsmain = oListModels.getObjectByJson_Sc_AssemblyBillMain2(msg2); |
| | | foreach (Model.ClsSc_AssemblyBillMain oItem in lsmain) |
| | | { |
| | | UserName = oItem.HMaker; //å¶å人 |
| | | oItem.HBillType = "3727"; |
| | | oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); |
| | | oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); |
| | | oItem.HBillStatus = 1; |
| | | oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿åå¤±è´¥ï¼æ²¡æåæ®æ¥æï¼æ æ³ä¿åï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | oBill.omodel = oItem; |
| | | } |
| | | //è¡¨ä½æ°æ® |
| | | //æ },{æ¥æåæ°ç» //廿ãåã |
| | | msg3 = msg3.Substring(1, msg3.Length - 2); |
| | | msg3 = msg3.Replace("\\", ""); |
| | | msg3 = msg3.Replace("\n", ""); //\n |
| | | //msg2 = msg2.Replace("'", "â"); |
| | | List<Model.ClsSc_AssemblyBillSub> ls = new List<Model.ClsSc_AssemblyBillSub>(); |
| | | ls = oListModels.getObjectByJson_Sc_AssemblyBillSub2(msg3); |
| | | int i = 0; |
| | | foreach (Model.ClsSc_AssemblyBillSub oItemSub in ls) |
| | | { |
| | | i++; |
| | | oItemSub.HEntryID = i; |
| | | |
| | | oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); |
| | | oItemSub.HCloseType = false; //å
³éç±»å |
| | | oItemSub.HUnitID = 0; |
| | | oItemSub.HQty = 1; |
| | | |
| | | oBill.DetailColl.Add(oItemSub); |
| | | } |
| | | |
| | | //ä¿å |
| | | //ä¿å宿¯åå¤ç |
| | | bool bResult; |
| | | bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | |
| | | if (bResult) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "ä¿åæåï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = 0; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region [å é¤ä¸´æ¶è¡¨æ°æ®] |
| | | [Route("Deltet_Sc_AssemblyBill_BindBarCodeTemp")] |
| | | [HttpGet] |
| | | public object Deltet_Sc_AssemblyBill_BindBarCodeTemp(string HBillNo, string HBarCode, string user) |
| | | { |
| | | DataSet ds; |
| | | try |
| | | { |
| | | if (string.IsNullOrWhiteSpace(HBillNo) || string.IsNullOrWhiteSpace(HBarCode)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "追溯åå·æé
ä»¶æ¡ç 为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.BeginTran();//å¼å§äºå¡ |
| | | ds = oCN.RunProcReturn("select * from Sc_AssemblyBill_BindBarCodeTemp where HBillNo_bak = '" + HBillNo + "' and HBarCode = '" + HBarCode + "'", "Sc_AssemblyBill_BindBarCodeTemp"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ²¡ææ°æ®ï¼æ æ³å é¤ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | |
| | | |
| | | oCN.RunProc("delete from Sc_AssemblyBill_BindBarCodeTemp where HBillNo_bak = '" + HBillNo + "' and HBarCode = '" + HBarCode + "'"); |
| | | oCN.Commit();//æäº¤äºå¡ |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "* æ°æ®å 餿åï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å é¤å¤±è´¥ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |