| | |
| | | using Dapper; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Linq; |
| | | using System.Web; |
| | | using VueWebApi.Hubs; |
| | | using VueWebApi.Models; |
| | | using VueWebApi.Tools; |
| | | |
| | |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备异常!"; |
| | | mes.Message = "当前设备/工位不存在或异常!"; |
| | | mes.data = data; |
| | | } |
| | | } |
| | |
| | | public static ToMessage AppDeviceCheckSave(string username, AppDevicecCheck json) |
| | | { |
| | | var sql = ""; |
| | | string djwo = ""; |
| | | string djwo = "", numvalue = ""; |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | mes = SeachEncode.EncodingSeach("1036"); //生成单号 |
| | | mes = SeachEncode.EncodingSeach("2040"); //生成单号 |
| | | if (mes.code == "300") |
| | | { |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | djwo = mes.data.GetType().GetProperty("Encode").GetValue(mes.data, null).ToString(); //获取单号 |
| | | List<string> wo = (List<string>)mes.data; |
| | | djwo = wo[0].ToString(); //获取单号 |
| | | numvalue = wo[1].ToString(); //获取流水号 |
| | | } |
| | | if (json == null || json.children.Count <= 0) |
| | | { |
| | |
| | | { |
| | | djwo = djwo, |
| | | eqp_code = json.code, |
| | | eqpchkmain_code=json.standcode, |
| | | eqpchkmain_code = json.standcode, |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString(), |
| | | chk_result=json.result |
| | | chk_result = json.result |
| | | } |
| | | }); |
| | | //循环写入点检记录子表 |
| | |
| | | { |
| | | seq = json.children[i].seq, |
| | | djwo = djwo, |
| | | eqpchkdeta_code =json.children[i].itemcode, |
| | | eqpchkdeta_code = json.children[i].itemcode, |
| | | chk_cyc = json.children[i].cycle, |
| | | result = json.children[i].result, |
| | | chk_value = json.children[i].value |
| | | } |
| | | }); ; |
| | | } |
| | | //回写字典表,更新当前流水号 |
| | | sql = @"update T_CodeRules set value=@cunm2 where rightcode=@RightCode"; |
| | | list.Add(new { str = sql, parm = new { cunm2 = numvalue, RightCode = "1027" } }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | |
| | | #endregion |
| | | |
| | | #region[日常保养,提交保存] |
| | | public static ToMessage AppDeviceRepairSave(string username,string maintcyc, AppDevicecCheck json) |
| | | public static ToMessage AppDeviceRepairSave(string username, string maintcyc, AppDevicecCheck json) |
| | | { |
| | | var sql = ""; |
| | | string djwo = ""; |
| | | string bywo = "", numvalue = ""; |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | mes = SeachEncode.EncodingSeach("1037"); //生成单号 |
| | | mes = SeachEncode.EncodingSeach("2041"); //生成单号 |
| | | if (mes.code == "300") |
| | | { |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | djwo = mes.data.GetType().GetProperty("Encode").GetValue(mes.data, null).ToString(); //获取单号 |
| | | List<string> wo = (List<string>)mes.data; |
| | | bywo = wo[0].ToString(); //获取单号 |
| | | numvalue = wo[1].ToString(); //获取流水号 |
| | | } |
| | | if (json == null || json.children.Count <= 0) |
| | | { |
| | |
| | | |
| | | //写入保养记录主表 |
| | | sql = @"insert into TEqpmaint_Proc_Main(bywo,eqp_code,eqpmaint_code,maint_cyc,maint_result,maint_user,maint_date) |
| | | values(@djwo,@eqp_code,@eqpmaint_code,@maintcyc,@maint_result,@lm_user,@lm_date)"; |
| | | values(@bywo,@eqp_code,@eqpmaint_code,@maintcyc,@maint_result,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | djwo = djwo, |
| | | bywo = bywo, |
| | | eqp_code = json.code, |
| | | eqpmaint_code = json.standcode, |
| | | maintcyc= maintcyc, |
| | | maintcyc = maintcyc, |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString(), |
| | | maint_result = json.result |
| | |
| | | for (int i = 0; i < json.children.Count; i++) |
| | | { |
| | | sql = @"insert into TEqpmaint_Proc_Deta(seq,bywo,eqpmaideta_code,result,maint_cyc,maint_value) |
| | | values(@seq,@djwo,@eqpmaideta_code,@maint_cyc,@result,@maint_value)"; |
| | | values(@seq,@bywo,@eqpmaideta_code,@result,@maint_cyc,@maint_value)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | seq = json.children[i].seq, |
| | | djwo = djwo, |
| | | bywo = bywo, |
| | | eqpmaideta_code = json.children[i].itemcode, |
| | | maint_cyc = json.children[i].cycle, |
| | | result = json.children[i].result, |
| | |
| | | } |
| | | }); ; |
| | | } |
| | | |
| | | //回写字典表,更新当前流水号 |
| | | sql = @"update T_CodeRules set value=@cunm2 where rightcode=@RightCode"; |
| | | list.Add(new { str = sql, parm = new { cunm2 = numvalue, RightCode = "1028" } }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | #region[测试安灯呼叫] |
| | | public static ToMessage AppDeviceAnDengCallSave(string eqpcode) |
| | | #region[设备维修申请,扫描工位/设备二维码] |
| | | public static ToMessage MaintainScanDeviceApplyQrCodeData(string eqpcode) |
| | | { |
| | | throw new NotImplementedException(); |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取当前扫码设备是否存在已申请或已维修状态数据 |
| | | sql = @"select * from TEqp_RepairRequest where eqp_code=@eqpcode and status<>'CONFIR'"; |
| | | dynamicParams.Add("@eqpcode", eqpcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | //查看维修记录里面是否有已申请未维修及维修确认的数据 |
| | | var rows = data0.AsEnumerable().Where(item => item["STATUS"].ToString().Equals("REPA")).ToArray(); |
| | | if (rows.Length > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备/工位已申请,待维修!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备/工位已维修,待确认验证!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //获取对应设备及所属车间 |
| | | sql = @"select A.code,A.name,T.org_code as wksp_code,T.org_name as wksp_name,E.eqpchkmain_code |
| | | from TEqpInfo A |
| | | left join TOrganization T on A.wksp_code=T.org_code |
| | | left join TEqpchk_Eqp E on A.code=E.eqp_code |
| | | where A.code=@eqpcode and A.enable='Y' and T.description='W'"; |
| | | dynamicParams.Add("@eqpcode", eqpcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备/工位不存在或异常!"; |
| | | mes.data = data; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[设备维修申请,提交保存] |
| | | public static ToMessage MaintainScanDeviceApplySave(string username, string eqpcode, string wkshpcode, string faultsourcecode, string faultdescr, HttpFileCollection files) |
| | | { |
| | | var sql = ""; |
| | | string wxwo = "", numvalue = ""; |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | mes = SeachEncode.EncodingSeach("2042"); //生成单号 |
| | | if (mes.code == "300") |
| | | { |
| | | mes.Message = "生成单号失败,请设置编码为【2042】的编码规则"; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | List<string> wo = (List<string>)mes.data; |
| | | wxwo = wo[0].ToString(); //获取单号 |
| | | numvalue = wo[1].ToString(); //获取流水号 |
| | | } |
| | | //验证上传图片 |
| | | if (files != null && files.Count > 0) |
| | | { |
| | | for (int i = 0; i < files.Count; i++) |
| | | { |
| | | HttpPostedFile file = files[i]; |
| | | string imgName = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString(); |
| | | string imgPath = "/DeviceImage/image1/" + imgName + file.FileName; //通过此对象获取文件名 |
| | | string AbsolutePath = System.Web.HttpContext.Current.Server.MapPath(imgPath); |
| | | file.SaveAs(AbsolutePath); //将上传的东西保存 |
| | | //循环写维修记录对应图片表 |
| | | sql = @"insert into TEqp_RepairImage(source_wo,wo_type,img1url) |
| | | values(@source_wo,@wo_type,@img1url)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | source_wo = wxwo, |
| | | wo_type = "REPA", |
| | | img1url = imgPath |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | //写入维修申请记录表 |
| | | sql = @"insert into TEqp_RepairRequest(docu_code,docu_date,status,wksp_code,eqp_code,request_person,request_date,failure_descript,source) |
| | | values(@docu_code,@docu_date,@status,@wksp_code,@eqp_code,@request_person,@request_date,@failure_descript,@source)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | docu_code = wxwo, |
| | | docu_date = DateTime.Now.ToString(), |
| | | status = "REPA", |
| | | wksp_code = wkshpcode, |
| | | eqp_code = eqpcode, |
| | | request_person = username, |
| | | request_date = DateTime.Now.ToString(), |
| | | failure_descript = faultdescr, |
| | | source = faultsourcecode |
| | | } |
| | | }); |
| | | //回写字典表,更新当前流水号 |
| | | sql = @"update T_CodeRules set value=@cunm2 where rightcode=@RightCode"; |
| | | list.Add(new { str = sql, parm = new { cunm2 = numvalue, RightCode = "2042" } }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "维修申请成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "维修申请失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[设备维修列表] |
| | | public static ToMessage RepairScanDeviceQrCodeDataList() |
| | | { |
| | | string sql = ""; |
| | | try |
| | | { |
| | | //获取设备维修列表已申请未维修的数据 |
| | | sql = @"select A.docu_code,B.code as eqpcode,B.name as eqpname, |
| | | T.org_code as wksp_code,T.org_name as wksp_name, |
| | | A.request_person,A.request_date, |
| | | (case when A.source='A' then '点检' when A.source='B' then '保养' when A.source='C' then '安灯' when A.source='D' then '手工' end) as source, |
| | | A.failure_descript |
| | | from TEqp_RepairRequest A |
| | | inner join TEqpInfo B on A.eqp_code=B.code |
| | | inner join TOrganization T on A.wksp_code=T.org_code |
| | | where T.description='W'and A.status='REPA'"; |
| | | var data = DapperHelper.selecttable(sql); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "暂无维修申请记录!"; |
| | | mes.data = data; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[设备维修提交] |
| | | public static ToMessage RepairScanDeviceSave(string docu_code, string username, string eqpcode, string wkshpcode, string faultdescr, string is_stoprepair, string repaircontent, string replaceparts, HttpFileCollection files) |
| | | { |
| | | var sql = ""; |
| | | string wxwo = "", numvalue = ""; |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | mes = SeachEncode.EncodingSeach("2043"); //生成单号 |
| | | if (mes.code == "300") |
| | | { |
| | | mes.Message = "生成单号失败,请设置编码为【2043】的编码规则"; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | List<string> wo = (List<string>)mes.data; |
| | | wxwo = wo[0].ToString(); //获取单号 |
| | | numvalue = wo[1].ToString(); //获取流水号 |
| | | } |
| | | //验证上传图片 |
| | | if (files != null && files.Count > 0) |
| | | { |
| | | for (int i = 0; i < files.Count; i++) |
| | | { |
| | | string imgPath1 = "", imgPath2 = "", AbsolutePath = ""; |
| | | HttpPostedFile file = files[i]; |
| | | string imgName = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString(); |
| | | string keyname = files.AllKeys[i].ToString().Substring(0, files.AllKeys[i].ToString().IndexOf(";")); |
| | | if (keyname == "files1") |
| | | { |
| | | imgPath1 = "/DeviceImage/image1/" + imgName + file.FileName; //通过此对象获取文件名 |
| | | AbsolutePath = System.Web.HttpContext.Current.Server.MapPath(imgPath1); |
| | | } |
| | | if (keyname == "files2") |
| | | { |
| | | imgPath2 = "/DeviceImage/image2/" + imgName + file.FileName; //通过此对象获取文件名 |
| | | AbsolutePath = System.Web.HttpContext.Current.Server.MapPath(imgPath2); |
| | | } |
| | | file.SaveAs(AbsolutePath); //将上传的东西保存 |
| | | //循环写维修记录对应图片表 |
| | | sql = @"insert into TEqp_RepairImage(source_wo,wo_type,img1url,img2url) |
| | | values(@source_wo,@wo_type,@img1url,@img2url)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | source_wo = wxwo, |
| | | wo_type = "COMP", |
| | | img1url = imgPath1, |
| | | img2url = imgPath2 |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | //写入维修记录表 |
| | | sql = @"insert into TEqp_Repair(repair_code,docu_date,status,wksp_code,eqp_code,repair_person,repair_date,repair_content,repair_part,failure_descript,is_shutdown,source_wo) |
| | | values(@repair_code,@docu_date,@status,@wksp_code,@eqp_code,@repair_person,@repair_date,@repair_content,@repair_part,@failure_descript,@is_shutdown,@source_wo)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | repair_code = wxwo, |
| | | docu_date = DateTime.Now.ToString(), |
| | | status = "COMP", |
| | | wksp_code = wkshpcode, |
| | | eqp_code = eqpcode, |
| | | repair_person = username, |
| | | repair_date = DateTime.Now.ToString(), |
| | | repair_content = repaircontent, |
| | | repair_part = replaceparts, |
| | | failure_descript = faultdescr, |
| | | is_shutdown = is_stoprepair, |
| | | source_wo = docu_code |
| | | } |
| | | }); |
| | | //更新维修申请单状态 |
| | | sql = @"update TEqp_RepairRequest set status=@status where docu_code=@docu_code and wksp_code=@wkshpcode and eqp_code=@eqpcode"; |
| | | list.Add(new { str = sql, parm = new { docu_code = docu_code, wkshpcode = wkshpcode, eqpcode = eqpcode, status = "COMP" } }); |
| | | |
| | | //回写字典表,更新当前流水号 |
| | | sql = @"update T_CodeRules set value=@cunm2 where rightcode=@RightCode"; |
| | | list.Add(new { str = sql, parm = new { cunm2 = numvalue, RightCode = "2043" } }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "维修申请成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "维修申请失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[维修验证列表] |
| | | public static ToMessage RepairVerificationScanDeviceData() |
| | | { |
| | | string sql = ""; |
| | | try |
| | | { |
| | | //获取设备维修列表已维修的数据 |
| | | sql = @"select A.repair_code,B.code as eqpcode,B.name as eqpname, |
| | | T.org_code as wksp_code,T.org_name as wksp_name, |
| | | A.repair_person,A.repair_date,A.is_shutdown, |
| | | A.failure_descript |
| | | from TEqp_Repair A |
| | | inner join TEqpInfo B on A.eqp_code=B.code |
| | | inner join TOrganization T on A.wksp_code=T.org_code |
| | | where T.description='W'and A.status='COMP'"; |
| | | var data = DapperHelper.selecttable(sql); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "暂无维修记录!"; |
| | | mes.data = data; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[维修验证详情信息] |
| | | public static ToMessage RepairVerificationScanDeviceDataSub(string repair_code, string eqpcode, string wkshpcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | Dictionary<string, object> dict = new Dictionary<string, object>(); |
| | | try |
| | | { |
| | | //根据设备编码\车间编码获取维修详情 |
| | | sql = @"select repair_code,failure_descript,is_shutdown,repair_content,repair_part |
| | | from TEqp_Repair |
| | | where repair_code=@repair_code and wksp_code=@wkshpcode and eqp_code=@eqpcode"; |
| | | dynamicParams.Add("@repair_code", repair_code); |
| | | dynamicParams.Add("@wkshpcode", wkshpcode); |
| | | dynamicParams.Add("@eqpcode", eqpcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | dict.Add("failure_descript", data.Rows[0]["failure_descript"].ToString()); //故障描述 |
| | | |
| | | //获取故障上传图片 |
| | | sql = @"select img1url from TEqp_RepairImage where source_wo=@source_wo and wo_type='COMP'"; |
| | | dynamicParams.Add("@source_wo", data.Rows[0]["repair_code"].ToString()); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | dict.Add("failure_descriptimg", data0); //故障上传图片 |
| | | } |
| | | if (data.Rows[0]["is_shutdown"].ToString() == "N") //是否停机维修 |
| | | { |
| | | dict.Add("repair_content", data.Rows[0]["repair_content"].ToString()); //维修内容 |
| | | dict.Add("repair_part", data.Rows[0]["repair_part"].ToString()); //更换备件 |
| | | |
| | | //获取更换备件上传图片 |
| | | sql = @"select img2url from TEqp_RepairImage where source_wo=@source_wo and wo_type='COMP'"; |
| | | dynamicParams.Add("@source_wo", data.Rows[0]["repair_code"].ToString()); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0) |
| | | { |
| | | dict.Add("repair_partimage", data1); //故障上传图片 |
| | | } |
| | | } |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = dict; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "暂无维修记录!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[维修验证提交] |
| | | public static ToMessage RepairVerificationScanDeviceSave(string username, string repairwo, string eqpcode, string wkshpcode, string result) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | //根据设备维修单查找源单(维修申请单) |
| | | sql = @"select source_wo from TEqp_Repair where repair_code=@repairwo"; |
| | | dynamicParams.Add("@repairwo", repairwo); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | //更新设备维修记录验证人员、验证时间、验证结果、验证状态 |
| | | sql = @"update TEqp_Repair set status=@status,is_verifi=@is_verifi,verify_result=@verify_result,verify_person=@verify_person,verify_date=@verify_date |
| | | where repair_code=@repair_code and wksp_code=@wksp_code and eqp_code=@eqp_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | status = "CONFIR", |
| | | is_verifi = "Y", |
| | | verify_result = result, |
| | | verify_person = username, |
| | | verify_date = DateTime.Now.ToString(), |
| | | repair_code = repairwo, |
| | | wksp_code = wkshpcode, |
| | | eqp_code = eqpcode |
| | | } |
| | | }); |
| | | //更新维修申请单状态 |
| | | sql = @"update TEqp_RepairRequest set status=@status where docu_code=@docu_code and wksp_code=@wkshpcode and eqp_code=@eqpcode"; |
| | | list.Add(new { str = sql, parm = new { docu_code = data.Rows[0]["source_wo"].ToString(), wkshpcode = wkshpcode, eqpcode = eqpcode, status = "CONFIR" } }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "维修验证成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "维修验证失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[安灯呼叫扫描工位] |
| | | public static ToMessage AppDeviceAnDengCallScanSearch(string eqpcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取对应设备及所属车间 |
| | | sql = @"select A.code,A.name,T.org_code as wksp_code,T.org_name as wksp_name,E.eqpchkmain_code |
| | | from TEqpInfo A |
| | | left join TOrganization T on A.wksp_code=T.org_code |
| | | left join TEqpchk_Eqp E on A.code=E.eqp_code |
| | | where A.code=@eqpcode and A.enable='Y' and T.description='W'"; |
| | | dynamicParams.Add("@eqpcode", eqpcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备/工位不存在或异常!"; |
| | | mes.data = data; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[安灯呼叫,选择扫描工位带出呼叫类型选项及对应人员数据] |
| | | public static ToMessage AppDeviceAnDengCallItemSearch(string eqpcode, string wkshpcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<AnDnDate> list = new List<AnDnDate>(); |
| | | try |
| | | { |
| | | //根据车间代码查找呼叫类型数据 |
| | | sql = @"select A.id,B.code,B.name,(case when F.type is null then 'N' else 'Y' end) flag |
| | | from TAnDon_Roul_ConFig A |
| | | inner join TAnDonType B on A.andotype_code=B.code |
| | | inner join TEqpInfo E on A.wkshp_code=e.wksp_code |
| | | left join( |
| | | select type,wkshp_code,eqp_code from TAnDon_Task_Info where eqp_code=@eqpcode and wkshp_code=@wkshpcode and status='START' |
| | | ) F on A.wkshp_code=F.wkshp_code and E.code=F.eqp_code and B.code=F.type |
| | | where A.wkshp_code=@wkshpcode and E.code=@eqpcode and A.enable='N'"; |
| | | dynamicParams.Add("@wkshpcode", wkshpcode); |
| | | dynamicParams.Add("@eqpcode", eqpcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | for (int i = 0; i < data.Rows.Count; i++) |
| | | { |
| | | AnDnDate mn = new AnDnDate(); |
| | | mn.code = data.Rows[i]["CODE"].ToString(); |
| | | mn.name = data.Rows[i]["NAME"].ToString(); |
| | | mn.flag = data.Rows[i]["FLAG"].ToString(); |
| | | mn.children = new List<AnDnDateSub>(); |
| | | //根据呼叫类型id查找绑定人员 |
| | | sql = @"select U.usercode,U.username,U.rid |
| | | from TAnDon_Roul_ConFigUser A |
| | | inner join TUser U on A.usercode=U.usercode |
| | | where A.ando_cogfigid=@id"; |
| | | dynamicParams.Add("@id", data.Rows[i]["ID"].ToString()); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | for (int j = 0; j < data0.Rows.Count; j++) |
| | | { |
| | | AnDnDateSub sn = new AnDnDateSub(); |
| | | sn.rid= data0.Rows[j]["RID"].ToString();//rid |
| | | sn.alias = data0.Rows[j]["RID"].ToString() + data0.Rows[j]["USERCODE"].ToString(); //别名 |
| | | sn.usercode = data0.Rows[j]["USERCODE"].ToString(); |
| | | sn.username = data0.Rows[j]["USERNAME"].ToString(); |
| | | mn.children.Add(sn); |
| | | } |
| | | } |
| | | list.Add(mn); |
| | | } |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = list; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备未设置安灯呼叫类型或者呼叫类型已关闭!"; |
| | | mes.data = data; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[安灯呼叫提交] |
| | | public static ToMessage AppDeviceAnDengCallSave(string username, string eqpcode, string wkshpcode, List<AnDnDate> json) |
| | | { |
| | | string sql = ""; |
| | | int AnDnID = 0; //最大id |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<object> list = new List<object>(); |
| | | List<string> list1 = new List<string>(); |
| | | ChatHub chthub = new ChatHub(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | //获取主表最大ID |
| | | AnDnID = DapperHelper.insertReturnId("TAnDon_Task_Info"); |
| | | for (int i = 0; i < json.Count; i++) |
| | | { |
| | | AnDnID = AnDnID + 1;//自增1 |
| | | string code = json[i].code.ToString(); |
| | | string name = json[i].name.ToString(); |
| | | sql = @"select * from TAnDon_Task_Info where wkshp_code=@wkshpcode and eqp_code=@eqpcode and type=@typecode and status='START'"; |
| | | dynamicParams.Add("@wkshpcode", wkshpcode); |
| | | dynamicParams.Add("@eqpcode", eqpcode); |
| | | dynamicParams.Add("@typecode", code); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备已经呼叫【" + name + "】,请先响应!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | //写入安灯呼叫表 |
| | | sql = @"insert into TAnDon_Task_Info(wkshp_code,eqp_code,type,start_date,start_user,status) |
| | | values(@wkshp_code,@eqp_code,@type,@start_date,@start_user,@status)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wkshp_code = wkshpcode, |
| | | eqp_code = eqpcode, |
| | | type = code, |
| | | start_date = DateTime.Now.ToString(), |
| | | start_user = username, |
| | | status = "START" |
| | | } |
| | | }); |
| | | |
| | | for (int j = 0; j < json[i].children.Count; j++) |
| | | { |
| | | //写入安灯记录推送人员表 |
| | | sql = @"insert into TAnDnMessagePush(m_id,wkshp_code,eqp_code,type,resp_user,status) |
| | | values(@m_id,@wkshp_code,@eqp_code,@type,@resp_user,@status)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | m_id = AnDnID, |
| | | //m_id = int.Parse(dt.Rows[0]["ID"].ToString()), |
| | | wkshp_code = wkshpcode, |
| | | eqp_code = eqpcode, |
| | | type = code, |
| | | resp_user = json[i].children[j].usercode, |
| | | alias= json[i].children[j].alias, |
| | | status = "N" |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | //极光推送 |
| | | mes = JPushManage.ExecutePushByUserId(username, wkshpcode, eqpcode, json); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "呼叫成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "呼叫失败!"; |
| | | mes.data = null; |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[安灯响应扫描工位/设备] |
| | | public static ToMessage AppDeviceAnDengLampResponseScanSearch(string eqpcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取对应设备及所属车间的安灯呼叫记录 |
| | | sql = @"select A.eqp_code,B.name as eqp_name,T.org_code as wksp_code,T.org_name as wksp_name,A.type as typecode,D.name as typename |
| | | from TAnDon_Task_Info A |
| | | left join TEqpInfo B on A.eqp_code=B.code |
| | | left join TOrganization T on B.wksp_code=T.org_code |
| | | left join TAnDonType D on A.type=D.code |
| | | where A.eqp_code=@eqpcode and A.status='START' and B.enable='Y' and T.description='W' "; |
| | | dynamicParams.Add("@eqpcode", eqpcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前设备/工位未安灯呼叫!"; |
| | | mes.data = data; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[安灯响应提交] |
| | | public static ToMessage AppDeviceAnDengLampResponseSave(string username, string eqpcode, string wkshpcode, List<ObjectData> json) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<object> list = new List<object>(); |
| | | ChatHub chthub = new ChatHub(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | for (int i = 0; i <json.Count; i++) |
| | | { |
| | | string code = json[i].code.ToString(); |
| | | string name = json[i].name.ToString(); |
| | | //更新安灯呼叫表 |
| | | sql = @"update TAnDon_Task_Info set resp_user=@resp_user,resp_date=@resp_date,status='CLOSED',taking=cast ( cast ( datediff ( ss, start_date, @resp_date) / ( 60 * 60 * 24 ) as int ) as varchar ) + '天' + |
| | | cast ( cast ( datediff ( ss, start_date, @resp_date ) % 86400 / 3600 as int ) as varchar ) + '小时' + |
| | | cast ( cast ( datediff ( ss, start_date, @resp_date ) % 3600 / 60 as int ) as varchar ) + '分' + |
| | | cast ( cast ( datediff ( ss, start_date, @resp_date ) % 60 as int ) as varchar ) + '秒' |
| | | where wkshp_code=@wkshp_code and eqp_code=@eqp_code and type=@type and status='START'"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wkshp_code = wkshpcode, |
| | | eqp_code = eqpcode, |
| | | type = code, |
| | | resp_date = DateTime.Now.ToString(), |
| | | resp_user = username, |
| | | status = "START" |
| | | } |
| | | }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "响应成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "响应失败!"; |
| | | mes.data = null; |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | } |