| | |
| | | { |
| | | HttpPostedFile file = files[i]; |
| | | string imgName = DateTime.Now.ToString("yyyyMMddhhmmss"); |
| | | string imgPath = "/DeviceImage/image1/" + file.FileName; //通过此对象获取文件名 |
| | | string imgPath = "/DeviceImage/image1/" + imgName + file.FileName; //通过此对象获取文件名 |
| | | string AbsolutePath = System.Web.HttpContext.Current.Server.MapPath(imgPath); |
| | | file.SaveAs(AbsolutePath); //将上传的东西保存 |
| | | //循环写维修记录对应图片表 |
| | |
| | | } |
| | | } |
| | | |
| | | //写入维修记录表 |
| | | //写入维修申请记录表 |
| | | 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 |
| | |
| | | eqp_code = eqpcode, |
| | | request_person = username, |
| | | request_date = DateTime.Now.ToString(), |
| | | failure_descript= faultdescr, |
| | | source=faultsourcecode |
| | | 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) |
| | | { |
| | |
| | | #endregion |
| | | |
| | | |
| | | #region[设备维修列表] |
| | | public static ToMessage RepairScanDeviceQrCodeData() |
| | | { |
| | | 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 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"); |
| | | string keyname = files.AllKeys[i].ToString(); |
| | | 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,img1_url,img2_url) |
| | | values(@source_wo,@wo_type,@img1_url,@img2_url)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | source_wo = wxwo, |
| | | wo_type = "COMP", |
| | | img1_url = imgPath1, |
| | | img2_url = 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) |
| | | values(@repair_code,@docu_date,@status,@wksp_code,@eqp_code,@repair_person,@repair_date,@repair_content,@repair_part,@failure_descript,@is_shutdown)"; |
| | | 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 |
| | | } |
| | | }); |
| | | |
| | | //回写字典表,更新当前流水号 |
| | | 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 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 wksp_code=@wkshpcode and eqp_code=@eqpcode"; |
| | | 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 img1ur2 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>(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | //更新设备维修记录验证人员、验证时间、验证结果、验证状态 |
| | | 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 |
| | | } |
| | | }); |
| | | |
| | | 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[安灯呼叫扫描工位] |