| | |
| | | using System.Web.Http; |
| | | using System.Windows.Forms; |
| | | using WebAPI.Models; |
| | | using System.Web; |
| | | using System.IO; |
| | | using WebAPI.Controllers.SCGL; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | | public class LMESController : ApiController |
| | |
| | | public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); |
| | | //自定义34进制数组 |
| | | private static char[] lNCode = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; |
| | | string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 返回进站扫描列表|工序进站接收单列表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | #region 返回进站扫描列表|工序进站接收单列表 |
| | | [Route("LEMS/MES_StationInBillList_Json")] |
| | | [HttpGet] |
| | | public object MES_StationInBillList_Json(string sWhere) |
| | |
| | | } |
| | | return GetObjectJson(ds); |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 返回工序流转卡维护列表主表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | #region 返回工序流转卡维护列表主表 |
| | | [Route("LEMS/MES_Sc_ProcessExchangeBillQuery_Json")] |
| | | [HttpGet] |
| | | public object MES_Sc_ProcessExchangeBillList_Json(string sWhere, string user,string HBillSubType) |
| | | public object MES_Sc_ProcessExchangeBillList_Json(string sWhere, string user, string HBillSubType) |
| | | { |
| | | DataSet ds; |
| | | try |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else { |
| | | else |
| | | { |
| | | |
| | | //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Query", 1, false, user)) |
| | |
| | | //获取需要拼接的字符串 |
| | | string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序派工单列表"); |
| | | |
| | | sWhere += sql_splice; |
| | | sWhere += sql_splice; |
| | | } |
| | | } |
| | | |
| | |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 工序流转卡维护-查询 |
| | | /// <summary> |
| | |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// 工序流转卡只显示工序染厂的数据 |
| | | /// </summary> |
| | | /// <param name="sWhere"></param> |
| | | /// <param name="user"></param> |
| | | /// <returns></returns> |
| | | #region 工序流转卡只显示工序染厂的数据 |
| | | [Route("LEMS/MES_ProcessExchangeBillList_Json")] |
| | | [HttpGet] |
| | | public object MES_ProcessExchangeBillList_Json(string sWhere, string user,int OperationType) |
| | | public object MES_ProcessExchangeBillList_Json(string sWhere, string user, int OperationType) |
| | | { |
| | | DataSet ds; |
| | | try |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (OperationType == 1) { |
| | | if (OperationType == 1) |
| | | { |
| | | //获取系统参数 |
| | | string Ret = ""; |
| | | if (oSystemParameter.ShowBill(ref Ret)) |
| | |
| | | sWhere += " and 工序='染厂' "; |
| | | |
| | | } |
| | | else { |
| | | else |
| | | { |
| | | sWhere += " and 工序='粗磨' "; |
| | | } |
| | | } |
| | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ds = oCN.RunProcReturn("select top 1000 * from h_v_Sc_ProcessExchangeBillList where 1 = 1 " + sWhere + " order by hmainid desc ", "h_v_Sc_ProcessExchangeBillList"); |
| | | } |
| | | else |
| | | else |
| | | { |
| | | //获取系统参数 |
| | | string Ret = ""; |
| | |
| | | //判断客户为龙山汽配 |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "乔一") |
| | | { |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeArrangementList where 1 = 1 " + sWhere , "h_v_Sc_ProcessExch_v_Sc_ProcessExchangeArrangementListhangeBillList"); |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeArrangementList where 1 = 1 " + sWhere, "h_v_Sc_ProcessExch_v_Sc_ProcessExchangeArrangementListhangeBillList"); |
| | | } |
| | | |
| | | //添加列名 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 工序流转卡只显示工序数据 |
| | | [Route("LEMS/MES_ProcessExchangeBillList_PG")] |
| | |
| | | oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=" + HSourceID + " where HInterID=" + HInterID + " and HEntryID=" + HEntryID); |
| | | |
| | | oCN.RunProc("exec h_p_Sc_ICMOBillStatus_Tmp_PG " + HInterID + "," + HEntryID); |
| | | |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "华舟") |
| | | { |
| | | oCN.RunProc("update Sc_ProcessExchangeBillMain set HMakeDate = GETDATE(),HMaker='"+ user + "' where HInterID = " + HInterID ); |
| | | |
| | | //自动生成工作联系单 |
| | | oCN.RunProc("exec h_p_OA_WorkLinkBill_Create " + HInterID + "," + 3772); |
| | | } |
| | | } |
| | | oCN.Commit(); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 工序流转卡批量派工(华舟) |
| | | [Route("LEMS/ProcessExchangeArrangement_Add_PGPL")] |
| | | [HttpPost] |
| | | public object ProcessExchangeArrangement_Add_PGPL([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 refSav = sArray[2].ToString();//操作方式数据类型 1添加 3修改 2 复制 |
| | | string msg4 = sArray[3].ToString();//用户名 |
| | | |
| | | try |
| | | { |
| | | // 反序列化子表数据 |
| | | var detailList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(msg3); |
| | | |
| | | foreach (var row in detailList) |
| | | { |
| | | // 3. 开始事务 |
| | | oCN.BeginTran(); |
| | | DataSet ds2 = null; |
| | | // 获取子表字段值 |
| | | string hSourceID = row.ContainsKey("HSourceID") ? row["HSourceID"] : "0"; |
| | | string hMoldID = row.ContainsKey("HMoldID") ? row["HMoldID"] : "0"; |
| | | string hSourceInterID = row.ContainsKey("HSourceInterID") ? row["HSourceInterID"] : "0"; |
| | | string hSourceEntryID = row.ContainsKey("HSourceEntryID") ? row["HSourceEntryID"] : "0"; |
| | | |
| | | if (hSourceID == "0" || hMoldID == "0") |
| | | { |
| | | continue; |
| | | } |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "华舟") |
| | | { |
| | | oCN.RunProc("update Sc_ProcessExchangeBillMain set HMakeDate = GETDATE(),HRemark3='已派工',HMaker='" + msg4 + "' where HInterID = " + hSourceInterID); |
| | | LogService.Write("自动生成工作联系单..."); |
| | | |
| | | //自动生成工作联系单 |
| | | ds2 = oCN.RunProcReturn("exec h_p_OA_WorkLinkBill_Create " + hSourceInterID + "," + 3772, "h_p_OA_WorkLinkBill_Create"); |
| | | } |
| | | } |
| | | oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=" + hSourceID + " where HInterID=" + hSourceInterID + " and HEntryID=" + hSourceEntryID); |
| | | // 插入生产状态临时表 |
| | | string SQL = $"exec h_p_Sc_ICMOBillStatus_Tmp_PGPL {hSourceInterID},{hSourceEntryID},{hSourceID},{hMoldID}"; |
| | | oCN.RunProc(SQL); |
| | | //插入工序流转卡派工单 |
| | | string SQL1 = $"exec h_p_Sc_ProcExchSendWorkBill_PG {hSourceInterID},{hSourceEntryID},{hSourceID},{hMoldID}"; |
| | | oCN.RunProc(SQL1); |
| | | |
| | | // 7. 提交事务 |
| | | oCN.Commit(); |
| | | if (ds2 != null && ds2.Tables[0].Rows.Count > 0) |
| | | { |
| | | int HInterID = int.Parse(ds2.Tables[0].Rows[0]["NewHInterID"].ToString()); |
| | | LogService.Write("执行消息推送..." + HInterID); |
| | | |
| | | // 触发消息推送 |
| | | Service.GeTuiService.PubishSingle(HInterID); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "派工信息保存成功!"; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + e.Message; |
| | | } |
| | | |
| | | return objJsonResult; |
| | | } |
| | | #endregion |
| | | |
| | | #region 取消派工功能(华舟) |
| | | [Route("LEMS/ProcessExchangeArrangementDel_PGHZ")] |
| | | [HttpGet] |
| | | public object ProcessExchangeArrangementDel_PGHZ(string HInterID_S, string user) |
| | | { |
| | | DataSet ds; |
| | | DataSet ds1; |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "流转卡无编辑权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | var HNum = HInterID_S.Split(','); |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | for (int j = 0; j < HNum.Length; j++) |
| | | { |
| | | |
| | | long HInterID = long.Parse(HNum[j].Split('|')[0]); |
| | | long HEntryID = long.Parse(HNum[j].Split('|')[1]); |
| | | long HSourceID = long.Parse(HNum[j].Split('|')[2]); |
| | | ds = oCN.RunProcReturn(@"select a.HMaterID,b.HProcID,a.HBillNo from Sc_ProcessExchangeBillMain a inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID where a.HInterID=" + HInterID + " and b.HEntryID=" + HEntryID, "Sc_ProcessExchangeBillMain"); |
| | | LogService.Write(1); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "查无此工序流转卡!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //根据主子ID+产线查询是否派工 |
| | | ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + " and HSourceID=" + HSourceID , "Sc_ICMOBillStatus_Tmp"); |
| | | LogService.Write(2); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "报工查无数据!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | LogService.Write(3); |
| | | oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=0 where HInterID=" + HInterID + " and HEntryID=" + HEntryID); |
| | | LogService.Write(4); |
| | | //更新掉已派工字段 |
| | | oCN.RunProc("update Sc_ProcessExchangeBillMain set HRemark3='' where HInterID=" + HInterID); |
| | | LogService.Write(5); |
| | | oCN.RunProc("delete from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + " and HSourceID=" + HSourceID); |
| | | LogService.Write(6); |
| | | //查询是否有出站单这个工单这个产线 |
| | | ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HProcExchInterID=" + HInterID + " and HProcExchEntryID=" + HEntryID + " and HSourceID=" + HSourceID + "", "Sc_StationOutBillMain"); |
| | | LogService.Write(7); |
| | | if (ds!=null && ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | //没有出站单的进行删除工序流转卡派工单 |
| | | oCN.RunProc("delete from Sc_ProcExchSendWorkBillMain where HInterID=(select HInterID from Sc_ProcExchSendWorkBillSub where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + " and HSourceID=" + HSourceID + " )"); |
| | | LogService.Write(8); |
| | | oCN.RunProc("delete from Sc_ProcExchSendWorkBillSub where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + " and HSourceID=" + HSourceID); |
| | | LogService.Write(9); |
| | | } |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | 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 排缸功能 |
| | | [Route("LEMS/ProcessExchangeArrangement_Add")] |
| | |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 返回工序流转卡维护列表从表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | #region 工序流转卡维护列表从表 |
| | | |
| | | [Route("LEMS/MES_Sc_ProcessExchangeBillQuerySub_Json")] |
| | | [HttpGet] |
| | | public object MES_Sc_ProcessExchangeBillSub_Json(string sWhere) |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 返回工序流转卡维护列表从表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | |
| | | #region 返回工序流转卡维护列表从表 |
| | | [Route("LEMS/MES_Sc_ProcessExchangeBillQueryCheckRecordSub_Json")] |
| | | [HttpGet] |
| | | public object MES_Sc_ProcessExchangeBillQueryCheckRecordSub_Json(string sWhere, int selected) |
| | |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | string sql = "exec h_p_ProcessExchangeBillCheckRecordList_GetSubBillList " + |
| | | "@sWhere = N'" + sWhere + "'" + |
| | | "@sWhere = N'" + sWhere + "'" + |
| | | ", @selected = N'" + selected + "'"; |
| | | ds = oCN.RunProcReturn(sql, "h_p_ProcessExchangeBillCheckRecordList_GetSubBillList"); |
| | | return GetObjectJson(ds); |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 工序流转卡(下达) |
| | | |
| | |
| | | } |
| | | return GetObjectJson(ds); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 返回工序流转卡列表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("LEMS/MES_Sc_ProcessExchangeBillList_Json")] |
| | | [HttpGet] |
| | | public object MES_Sc_ProcessExchangeBillList_Json(string sWhere, string user) |
| | | { |
| | | DataSet ds; |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>() |
| | | ; //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBillQuery", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限查询!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //获取系统参数 |
| | | string Ret = ""; |
| | | if (oSystemParameter.ShowBill(ref Ret)) |
| | | { |
| | | //判断客户为龙山汽配 |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") |
| | | { |
| | | //获取需要拼接的字符串 |
| | | string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "生产订单列表"); |
| | | |
| | | sWhere += sql_splice; |
| | | } |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuery where 1 = 1 " + sWhere + " order by 制单日期 desc,单据号 desc", "h_v_Sc_ProcessExchangeBillQuery"); |
| | | //添加列名 |
| | | 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列对象的列名 |
| | | } |
| | | |
| | | //if (ds.Tables[0].Rows.Count != 0 || ds != null) |
| | | //{ |
| | | //objJsonResult.code = "1"; |
| | | //objJsonResult.count = 1; |
| | | //objJsonResult.Message = "Sucess!"; |
| | | //objJsonResult.data = ds.Tables[0]; |
| | | //objJsonResult.list = a; |
| | | //return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "没有返回任何记录!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | return GetObjectJson(ds); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | #region 生产订单列表-分页 |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 多级审核审核列表 |
| | | [Route("LEMS/CheckFlowList")] |
| | | [HttpGet] |
| | | public json CheckFlowList(string sWhere, string billType, int type, string userid) |
| | | { |
| | | DataSet ds; |
| | | json res = new json(); |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn($"exec h_p_Xt_CheckFlowList '','{billType}',{type},'{userid}'", "h_p_Xt_CheckFlowList"); |
| | | } |
| | | else |
| | | { |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | ds = oCN.RunProcReturn($"exec h_p_Xt_CheckFlowList '{sWhere}','{billType}',{type},'{userid}'", "h_p_Xt_CheckFlowList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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列对象的列名 |
| | | } |
| | | |
| | | res.code = CodeConstant.SUCCEED; |
| | | res.count = 1; |
| | | res.Message = "Sucess!"; |
| | | res.list = columnNameList; |
| | | res.data = ds.Tables[0]; |
| | | return res; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | res.code = CodeConstant.FAIL; |
| | | res.count = CountConstant.FAIL; |
| | | res.Message = "Exception!" + e.ToString(); |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 反审核意见提交 |
| | | [Route("LMES/AuditFlowOpinion")] |
| | | [HttpGet] |
| | | public json AuditFlowOpinion(string sWhere,string billType,int HInterID, int type, string user) |
| | | { |
| | | DataSet ds; |
| | | json res = new json(); |
| | | try |
| | | { |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn($"exec h_p_Xt_AuditFlowOpinion '','{billType}',{HInterID},{type},'{user}'", "h_p_Xt_AuditFlowOpinion"); |
| | | } |
| | | else |
| | | { |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | ds = oCN.RunProcReturn($"exec h_p_Xt_AuditFlowOpinion '{sWhere}','{billType}',{HInterID},{type},'{user}'", "h_p_Xt_AuditFlowOpinion"); |
| | | } |
| | | |
| | | if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反审核意见提交失败"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反审核意见提交失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | res.code = CodeConstant.SUCCEED; |
| | | res.count = 1; |
| | | res.Message = "Sucess!"; |
| | | res.data = ds.Tables[0].Rows[0]["HRemark"]; |
| | | return res; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | res.code = CodeConstant.FAIL; |
| | | res.count = CountConstant.FAIL; |
| | | res.Message = "Exception!" + e.ToString(); |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region app文件上传通用接口 |
| | | [Route("LMES/UploadFile")] |
| | | [HttpPost] |
| | | public object UploadFile() |
| | | { |
| | | |
| | | string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //单据号 |
| | | string HRemark = HttpContext.Current.Request.Params["HRemark"]; //备注 |
| | | string HUserName = HttpContext.Current.Request.Params["HUserName"]; //创建人 |
| | | HttpPostedFile files = HttpContext.Current.Request.Files["file"]; |
| | | string path = HttpContext.Current.Server.MapPath("~/../Files/APPFolder/" + HBillNo); |
| | | //string path = @"D:\\Files\\"+ HBillNo; |
| | | dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); |
| | | if (dyResult != null && dyResult.result == 1) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "上传成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = dyResult.returnval; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | |
| | | public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) |
| | | { |
| | | dynamic Result_Ob = new { result = 1, returnval = "上传成功!" }; |
| | | string filePath = Path.GetFullPath(files.FileName);//文件上传路径 |
| | | string fileExtension = Path.GetExtension(files.FileName);// 文件扩展名 |
| | | string filename = files.FileName;//文件名 |
| | | string fileSavePath = path;// 上传保存路径 |
| | | int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte |
| | | int Maxsize = 40000 * 1024;//定义上传文件的最大空间大小为40M |
| | | DataSet ds = new DataSet(); |
| | | try |
| | | { |
| | | if (files == null || files.ContentLength <= 0) |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "文件不能为空!" }; |
| | | return Result_Ob; |
| | | } |
| | | if (filesize >= Maxsize) |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "上传文件超过40M,不能上传!" }; |
| | | return Result_Ob; |
| | | } |
| | | |
| | | string fileurl = Path.Combine(fileSavePath, filename); |
| | | if (Directory.Exists(fileurl) == true) //如果存在重名文件就提示 |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "存在同名文件!" }; |
| | | return Result_Ob; |
| | | } |
| | | //删除数据表数据 |
| | | ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); |
| | | if (Directory.Exists(path)) |
| | | { |
| | | File.Delete(fileurl); //删除指定文件 |
| | | files.SaveAs(fileurl); |
| | | string StrPath = "/files/APPFolder/" + HBillNo + "/" + filename; |
| | | if (File.Exists(fileurl)) |
| | | { |
| | | //这里可以执行一些其它的操作,比如更新数据库 |
| | | //写入数据表 |
| | | oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + |
| | | ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + |
| | | ",HFileClsID,HSourceBillNo" + |
| | | ") values('" |
| | | + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + |
| | | ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + |
| | | "','" + 0 + "','" + HBillNo + |
| | | "') "); |
| | | } |
| | | else |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Directory.CreateDirectory(fileSavePath); //添加文件夹 |
| | | files.SaveAs(fileurl); |
| | | string StrPath = "/files/APPFolder/" + HBillNo + "/" + filename; |
| | | if (File.Exists(fileurl)) |
| | | { |
| | | //这里可以执行一些其它的操作,比如更新数据库 |
| | | //写入数据表 |
| | | oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + |
| | | ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + |
| | | ",HFileClsID,HSourceBillNo" + |
| | | ") values('" |
| | | + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + |
| | | ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + |
| | | "','" + 0 + "','" + HBillNo + |
| | | "') "); |
| | | } |
| | | else |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Result_Ob = new { result = 0, returnval = e.Message }; |
| | | } |
| | | return Result_Ob; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据单据号查找上传文件列表 |
| | | /// </summary> |
| | | /// <param name="sWhere"></param> |
| | | /// <returns></returns> |
| | | [Route("LMES/Filelist")] |
| | | [HttpGet] |
| | | public object Filelist(string HBillNo) |
| | | { |
| | | DataSet ds = new DataSet(); |
| | | var url = fileip + "/files/APPFolder/" + HBillNo + "/"; |
| | | //@"C:\\files\\" |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据ID,单据号,文件名 删除文件 |
| | | /// </summary> |
| | | /// <param name="sWhere"></param> |
| | | /// <returns></returns> |
| | | [Route("LMES/DeleteFilelist")] |
| | | [HttpGet] |
| | | public object DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) |
| | | { |
| | | try |
| | | { |
| | | |
| | | oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); |
| | | string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/EquipFolder/" + HSourceBillNo), HFileName); |
| | | File.Delete(fileurl); //删除指定文件 |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | } |
| | | } |