| | |
| | | using System.Data.SqlClient; |
| | | using System.Linq; |
| | | using System.Web; |
| | | using VueWebApi.Models; |
| | | using VueWebApi.Tools; |
| | | |
| | | namespace VueWebApi.DLL.DAL |
| | |
| | | |
| | | |
| | | #region[ERP订单查询] |
| | | public static ToMessage ErpOrderSearch(string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string creatuser, string createstartdate, string createenddate, int endNum, string prop, string order) |
| | | public static ToMessage ErpOrderSearch(string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string paydatestartdate1, string paydateenddate2, string creatuser, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | } |
| | | if (paydatestartdate != "" && paydatestartdate != null) |
| | | { |
| | | search += "and A.paydate between @paydatestartdate and @paydateenddate "; |
| | | dynamicParams.Add("@paydatestartdate", paydatestartdate+" 00:00:00"); |
| | | search += "and A.planstartdate between @paydatestartdate and @paydateenddate "; |
| | | dynamicParams.Add("@paydatestartdate", paydatestartdate + " 00:00:00"); |
| | | dynamicParams.Add("@paydateenddate", paydateenddate + " 23:59:59"); |
| | | } |
| | | if (createstartdate != "" && createstartdate != null) |
| | | if (paydatestartdate1 != "" && paydatestartdate1 != null) |
| | | { |
| | | search += "and A.createdate between @createstartdate and @createenddate "; |
| | | dynamicParams.Add("@createstartdate", createstartdate); |
| | | dynamicParams.Add("@createenddate", createenddate + " 23:59:59"); |
| | | search += "and A.planenddate between @paydatestartdate1 and @paydateenddate2 "; |
| | | dynamicParams.Add("@paydatestartdate1", paydatestartdate1); |
| | | dynamicParams.Add("@paydateenddate2", paydateenddate2 + " 23:59:59"); |
| | | } |
| | | if (creatuser != "" && creatuser != null) |
| | | { |
| | | search += "and A.createuser like '%'+@creatuser+'%' "; |
| | | search += "and U.username like '%'+@creatuser+'%' "; |
| | | dynamicParams.Add("@creatuser", creatuser); |
| | | } |
| | | |
| | |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.paydate,A.createuser,A.createdate |
| | | A.stck_code,D.name as stck_name,A.planstartdate,A.planenddate,U.username as createuser,A.createdate |
| | | from TKimp_Ewo A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code where A.is_delete<>'1' " + search; |
| | | left join T_Sec_Stck D on A.stck_code=D.code |
| | | left join TUser U on A.createuser=U.usercode |
| | | where A.is_delete<>'1' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | } |
| | | if (creatuser != "" && creatuser != null) |
| | | { |
| | | search += "and A.lm_user like '%'+@creatuser+'%' "; |
| | | search += "and U.username like '%'+@creatuser+'%' "; |
| | | dynamicParams.Add("@creatuser", creatuser); |
| | | } |
| | | |
| | |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.status,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.m_po,A.lm_user,A.lm_date |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.m_po,U.username as lm_user,A.lm_date |
| | | from TK_Wrk_Man A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code |
| | | left join TFlw_Rout E on A.route_code=E.code |
| | | left join T_Sec_Stck F on A.stck_code=F.code where A.is_delete<>'1' " + search; |
| | | left join T_Sec_Stck F on A.stck_code=F.code |
| | | left join TUser U on A.lm_user=U.usercode |
| | | where A.is_delete<>'1' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | planenddate = planenddate, |
| | | status = "ALLO", //派发 |
| | | username = username, |
| | | routecode= routecode, |
| | | routecode = routecode, |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | |
| | | sql = @"select * from TStep where stepcode=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | |
| | | dynamicParams.Add("@usercode", usercode); |
| | | } |
| | | //班组获取人员列表 |
| | | sql = @"select usercode,username from TUser where is_delete<>'1' "+search; |
| | | sql = @"select usercode,username from TUser where is_delete<>'1' " + search; |
| | | dynamicParams.Add("@usercode", usercode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | |
| | | left join TCustomer C on A.eqp_code=C.code |
| | | where A.step_code=@stepcode and A.style='W'"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql,dynamicParams); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | if (badcode != "" && ngqty != "0") |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | |
| | | |
| | | //回写工单工序表合格数量、不良数量 |
| | | sql = @"update TK_Wrk_Step set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode and step_code=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode,reportqty=reportqty,ngqty=ngqty } }); |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, reportqty = reportqty, ngqty = ngqty } }); |
| | | |
| | | //回写工单表合格数量、不良数量 |
| | | sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | |
| | | } |
| | | #endregion' |
| | | |
| | | #region[生产开报工,工序检验扫码获取任务信息] |
| | | public static ToMessage MesOrderStepCheckSearch(string orderstepqrcode) |
| | | { |
| | | var sql = ""; |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | | { |
| | | string[] arra = orderstepqrcode.Split(';'); |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序条码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | //通过扫描二维码信息查找任务信息 |
| | | sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,S.stepcode,S.stepname |
| | | from TK_Wrk_Step A |
| | | inner join TK_Wrk_Man P on A.wo_code=P.wo_code |
| | | left join TMateriel_Info M on P.materiel_code=M.partcode |
| | | left join TStep S on A.step_code=S.stepcode |
| | | where A.wo_code=@wo_code and A.step_code=@stepcode"; |
| | | dynamicParams.Add("@wo_code", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "生产任务不存在!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "二维码信息为空!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工,工序检验获取检验标准下拉框数据] |
| | | public static ToMessage MesOrderStepCheckSelect() |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取工序检验标准 |
| | | sql = @"select code,name from TStepCheckStandard where is_delete<>'1'"; |
| | | var data = DapperHelper.selecttable(sql); |
| | | mes.code = "200"; |
| | | 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 MesOrderStepCheckItemList(string checkstandcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //根据检验标准编码获取工序检验项目 |
| | | sql = @"select B.code,B.name,A.stepcheckitem_desc,A.stepcheckitem_seq from TStepCheckStandardSub A |
| | | left join TStepCheckItem B on A.stepcheckitem_code=B.code |
| | | where B.is_delete<>'1' and A.stepstaned_code=@checkstandcode"; |
| | | dynamicParams.Add("@checkstandcode", checkstandcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | 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 SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkuser, string checktypecode, string checkresult, string checkdescr, string username, List<StepCheck> json) |
| | | { |
| | | var sql = ""; |
| | | string[] arra = new string[] { }; |
| | | string[] arra1 = new string[] { }; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | string date = DateTime.Now.ToString(); //获取系统时间 |
| | | |
| | | list.Clear(); |
| | | |
| | | //写入工序检验记录主表 |
| | | sql = @"insert into TStepCheckRecord(wo_code,part_code,step_code,checkstaned_code,check_user,check_type,check_result,check_descr,lm_user,lm_date) |
| | | values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkuser,@checktypecode,@checkresult,@checkdescr,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkuser = checkuser, checktypecode = checktypecode, checkresult = checkresult, checkdescr = checkdescr, lm_user = username, lm_date = date } }); |
| | | //写入工序检验记录子表 |
| | | //获取主表最大ID |
| | | sql = @"select IDENT_CURRENT('TStepCheckRecord')+1 as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | for (int i = 0; i < json.Count; i++) |
| | | { |
| | | sql = @"insert into TStepCheckRecordSub(m_id,checkiem_seq,checkitem_code,checkitem_name,checkitem_descr,check_result,lm_user,lm_date) |
| | | values(@m_id,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_result,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), checkiem_seq = int.Parse(json[i].seq), checkitem_code = json[i].code, checkitem_name = json[i].name, checkitem_descr = json[i].descr, check_result = json[i].checkresult, lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | |
| | | 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 |
| | | |
| | | } |
| | | } |