New file |
| | |
| | | using DBUtility; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | | public class Gy_UnitConvertRateController : ApiController |
| | | { |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus; |
| | | const string ModCaption = "å使¢ç®"; |
| | | public const string ModRightName = "Gy_UnitConvertRate"; |
| | | public const string ModRightNameDelete = ModRightName + "_Delete"; //å é¤ |
| | | public DataSet ds = new DataSet(); |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | |
| | | |
| | | #region å使¢ç®å表 |
| | | /// <summary> |
| | | /// è·åå使¢ç®åè¡¨ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Gy_UnitConvertRateController/GetGy_UnitConvertRateList_Json")] |
| | | [HttpGet] |
| | | public object GetGy_UnitConvertRateList_Json(string sWhere, string HMaker, string OperationType) |
| | | { |
| | | try |
| | | { |
| | | //夿æé 1ä¸ºç´æ¥å表模åæå¼ 2为ä»å
¶ä»æ¨¡å跳转æå¼å表 |
| | | if (OperationType == "1") |
| | | { |
| | | //夿æé |
| | | if (!DBUtility.ClsPub.Security_Log(ModRightName, 1, false, HMaker)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¨æ²¡æè¯¥æ¨¡åæé,请ä¸ç®¡çåèç³»ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //è¿ååè¡¨ä¿¡æ¯ |
| | | ds = oCn.RunProcReturn("select * from h_v_Gy_UnitConvertRateList where " + sWhere + " order by HItemID desc", "h_v_Gy_UnitConvertRateList"); |
| | | List<object> columnNameList = new List<object>(); |
| | | //æ·»å åå |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString)); //è·åå°DataColumnå对象çåå |
| | | } |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "æåï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¥è¯¢å表信æ¯å¤±è´¥ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region å使¢ç®å é¤ |
| | | /// <summary> |
| | | /// å é¤å使¢ç® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Gy_UnitConvertRateController/GetGy_UnitConvertRate_Delete_Json")] |
| | | [HttpGet] |
| | | public object GetGy_UnitConvertRate_Delete_Json(Int64 HItemID, string HMaker) |
| | | { |
| | | try |
| | | { |
| | | //夿æé |
| | | if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, false, HMaker)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¨æ²¡æè¯¥æ¨¡åå é¤åè½æé,请ä¸ç®¡çåèç³»ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCn.BeginTran(); |
| | | //夿å卿§ |
| | | ds = oCn.RunProcReturn("select HNumber,HName from Gy_UnitConvertRate with(nolock) where HItemID= " + HItemID.ToString(), "Gy_UnitConvertRate"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCn.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æªæ¥è¯¢å°è¯¥å使¢ç®ï¼è¯·å·æ°æ°æ®åéæ°éæ©ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | oCn.RunProc("Delete from Gy_UnitConvertRate where HItemID= " + HItemID.ToString(), ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //åå
¥æ¥å¿ |
| | | DBUtility.ClsPub.Add_Log("", "å é¤å使¢ç®ï¼ä»£ç ï¼" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HNumber"]) + ",åç§°ï¼" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HName"]), HMaker); |
| | | oCn.Commit(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å é¤å使¢ç®æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCn.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å é¤å使¢ç®å¤±è´¥ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region å使¢ç®æ¹é忥 |
| | | /// <summary> |
| | | /// ä»éè¶äºæ¹é忥å使¢ç®è³æ¬å°è¡¨ |
| | | /// </summary> |
| | | [Route("Gy_UnitConvertRateController/GetGy_UnitConvertRate_BatchSync_Json")] |
| | | [HttpGet] |
| | | public object GetGy_UnitConvertRate_BatchSync_Json() |
| | | { |
| | | try |
| | | { |
| | | //è·åç³»ç»åæ° |
| | | string sErrMsg = ""; |
| | | if (oSystemParameter.ShowBill(ref sErrMsg) == true) |
| | | { |
| | | //ç³»ç»åæ°æ¯å¦ä¸ºç§æäºæ¨¡å¼,N为å
¬æäºæ¨¡å¼ï¼Yä¸ºç§æäºæ¨¡å¼ |
| | | //ç§æäºæ¨¡å¼ï¼éè¿è°ç¨åå¨è¿ç¨è¿è¡åæ¥ |
| | | if (oSystemParameter.omodel.WMS_CloudMode.ToUpper() == "Y") |
| | | { |
| | | ds = oCn.RunProcReturn("exec h_p_IFCLD_ERPDataToLocal_UnitConvertRate", "h_p_IFCLD_ERPDataToLocal_UnitConvertRate"); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å使¢ç®æ¹é忥æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //å
¬æäºæ¨¡å¼ï¼éè¿è°ç¨WEBAPIæ¹å¼è¿è¡åæ¥ |
| | | else if (oSystemParameter.omodel.WMS_CloudMode.ToUpper() == "N") |
| | | { |
| | | //夿éè¶äºæ¯å¦ç»å½æå |
| | | var loginRet = InvokeHelper.Login(); |
| | | var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); |
| | | //夿æ¯å¦ç»å½æå |
| | | if (isSuccess <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¹éåæ¥å¤±è´¥ï¼éè¶äºç»å
¥ä¸æåï¼è¯·ç¡®è®¤Cçé
ç½®æä»¶æè®¾ç½®éè¶äºå¯¹åºç½åãè´¦å¥ãç»å½ç¨æ·ãç»å½å¯ç æ¯å¦æ£ç¡®ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | var json = new |
| | | { |
| | | FormId = "BD_UNITCONVERTRATE", |
| | | FieldKeys = "FUNITCONVERTRATEID,FBILLNO,FMATERIALID,FUSEORGID,FCREATEORGID,FFORBIDSTATUS" + |
| | | ",FCURRENTUNITID,FDESTUNITID,FCONVERTTYPE,FCONVERTNUMERATOR,FCONVERTDENOMINATOR" + |
| | | ",FCREATORID,FCREATEDATE,FMODIFIERID,FMODIFYDATE,FAPPROVERID,FAPPROVEDATE,FFORBIDDERID,FFORBIDDATE", |
| | | FilterString = "", |
| | | OrderString = "", |
| | | TopRowCount = 0, |
| | | StartRow = 0, |
| | | Limit = 0 |
| | | }; |
| | | //æ¥ç è·åæ°æ® |
| | | var _result = InvokeHelper.Query("BD_UNITCONVERTRATE", JsonConvert.SerializeObject(json)); |
| | | |
| | | //ååºåå |
| | | _result = _result.Replace("\"", ""); |
| | | _result = _result.Replace("\n", ""); |
| | | _result = _result.Replace(",[", ""); |
| | | _result = _result.Replace("[", ""); |
| | | string[] rows = _result.Split(new string[] { "]" }, StringSplitOptions.RemoveEmptyEntries); //以"]"å鿝ä¸è¡å¹¶ç§»é¤ç©ºè¡ |
| | | string[,] arr = new string[rows.Length, rows[0].Split(',').Length]; //æ ¹æ®è¡ååæ°å建äºç»´æ°ç» |
| | | for (int i = 0; i < rows.Length; i++) //é忝ä¸è¡ |
| | | { |
| | | string[] cols = rows[i].Split(','); //以éå·å鿝ä¸å |
| | | for (int j = 0; j < cols.Length; j++) //é忝ä¸å |
| | | { |
| | | arr[i, j] = cols[j]; //åå
¥äºç»´æ°ç» |
| | | } |
| | | } |
| | | //æ¸
空å使¢ç®è¡¨æ°æ® |
| | | oCn.RunProc("Delete from Gy_UnitConvertRate", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | //è¾åºäºç»´æ°ç» |
| | | for (int i = 0; i < arr.GetLength(0); i++) |
| | | { |
| | | var subData = new |
| | | { |
| | | HItemID = DBUtility.ClsPub.isLong(arr[i, 0]), |
| | | HNumber = "", |
| | | HName = "", |
| | | HShortNumber = "", |
| | | HParentID = 0, |
| | | HLevel = 1, |
| | | HEndFlag = 1, |
| | | HStopflag = arr[i, 5].ToString() == "B" ? 1 : 0, |
| | | HRemark = "CLD-ERP导å
¥", |
| | | HUseFlag = "已使ç¨", |
| | | HUSEORGID = DBUtility.ClsPub.isLong(arr[i, 3]), |
| | | HCREATEORGID = DBUtility.ClsPub.isLong(arr[i, 4]), |
| | | HBILLNO = DBUtility.ClsPub.isStrNull(arr[i, 1]), |
| | | HMATERID = DBUtility.ClsPub.isLong(arr[i, 2]), |
| | | HCURRENTUNITID = DBUtility.ClsPub.isLong(arr[i, 6]), |
| | | HDESTUNITID = DBUtility.ClsPub.isLong(arr[i, 7]), |
| | | HCONVERTTYPE = DBUtility.ClsPub.isStrNull(arr[i, 8]), |
| | | HCONVERTNUMERATOR = DBUtility.ClsPub.isDoule(arr[i, 9]), |
| | | HCONVERTDENOMINATOR = DBUtility.ClsPub.isDoule(arr[i, 10]), |
| | | HFORBIDSTATUS = DBUtility.ClsPub.isStrNull(arr[i, 5]), |
| | | HUnitID = DBUtility.ClsPub.isLong(arr[i, 2] == "0" ? arr[i, 6] : "-1"), |
| | | HMakeEmp = DBUtility.ClsPub.isStrNull(arr[i, 11]), |
| | | HMakeTime = DBUtility.ClsPub.isDate(arr[i, 12]), |
| | | HCheckEmp = DBUtility.ClsPub.isStrNull(arr[i, 15]), |
| | | HCheckTime = DBUtility.ClsPub.isDate(arr[i, 16]), |
| | | HModifyEmp = DBUtility.ClsPub.isStrNull(arr[i, 13]), |
| | | HModifyTime = DBUtility.ClsPub.isDate(arr[i, 14]), |
| | | HStopEmp = DBUtility.ClsPub.isStrNull(arr[i, 17]), |
| | | HStopTime = DBUtility.ClsPub.isDate(arr[i, 18]), |
| | | }; |
| | | |
| | | //åå
¥å使¢ç®è¡¨æ°æ® |
| | | oCn.RunProc("set identity_insert Gy_UnitConvertRate on", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | string sql = $@"Insert into Gy_UnitConvertRate |
| | | (HItemID,HNumber,HName,HShortNumber,HParentID,HLevel |
| | | ,HEndFlag,HStopflag,HRemark,HUseFlag,HUSEORGID,HCREATEORGID |
| | | ,HBILLNO,HMATERID,HCURRENTUNITID,HDESTUNITID,HCONVERTTYPE,HCONVERTNUMERATOR |
| | | ,HCONVERTDENOMINATOR,HFORBIDSTATUS,HUnitID |
| | | ,HMakeEmp,HMakeTime |
| | | ,HCheckEmp,HCheckTime |
| | | ,HModifyEmp,HModifyTime |
| | | ,HStopEmp,HStopTime) |
| | | Values({subData.HItemID},'{subData.HNumber}','{subData.HName}','{subData.HShortNumber}',{subData.HParentID},{subData.HLevel} |
| | | ,{subData.HEndFlag},{subData.HStopflag},'{subData.HRemark}','{subData.HUseFlag}',{subData.HUSEORGID},{subData.HCREATEORGID} |
| | | ,'{subData.HBILLNO}',{subData.HMATERID},{subData.HCURRENTUNITID},{subData.HDESTUNITID},{subData.HCONVERTTYPE},{subData.HCONVERTNUMERATOR} |
| | | ,{subData.HCONVERTDENOMINATOR},'{subData.HFORBIDSTATUS}',{subData.HUnitID} |
| | | ,'{subData.HMakeEmp}',case when '{subData.HMakeTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HMakeTime}' end |
| | | ,'{subData.HCheckEmp}',case when '{subData.HCheckTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HCheckTime}' end |
| | | ,'{subData.HModifyEmp}',case when '{subData.HModifyTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HModifyTime}' end |
| | | ,'{subData.HStopEmp}',case when '{subData.HStopTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HStopTime}' end)"; |
| | | oCn.RunProc(sql.Replace("\r\n", "")); |
| | | oCn.RunProc("set identity_insert Gy_UnitConvertRate off", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å使¢ç®æ¹é忥æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "䏿¯ææ¹é忥åè½ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "è·åç³»ç»åæ°å¤±è´¥ï¼ " + sErrMsg; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å使¢ç®æ¹éåæ¥å¤±è´¥ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |