| | |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工艺路线对应工序【"+dtck.Rows[i]["step_code"].ToString()+"】,未关联设备,请关联所有工序对应设备!"; |
| | | mes.Message = "当前工艺路线对应工序【" + dtck.Rows[i]["step_code"].ToString() + "】,未关联设备,请关联所有工序对应设备!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | |
| | | where C.step_code=@step_code"; |
| | | dynamicParams.Add("@step_code", dtck1.Rows[i]["step_code"].ToString()); |
| | | var dtck2 = DapperHelper.selectdata(sql, dynamicParams); |
| | | int query = dtck2.AsEnumerable().Where<DataRow>(a => a["enable"].ToString() =="N").Count(); |
| | | if (dtck2.Rows.Count == query) |
| | | int query = dtck2.AsEnumerable().Where<DataRow>(a => a["enable"].ToString() == "N").Count(); |
| | | if (dtck2.Rows.Count == query) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | |
| | | } |
| | | //根据条件查询工单工序任务,且不良数量大于0 |
| | | sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,A.seq,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,B.lm_date |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工,报工提交] |
| | | public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string reckway, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string remarks, string username) |
| | | public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string remarks, string username) |
| | | { |
| | | var sql = ""; |
| | | //string[] arra = new string[] { }; |
| | |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入开报工记录表 |
| | | sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date) |
| | | values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date } }); |
| | | sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date,inbarcode) |
| | | values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date,@inbarcode)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date, inbarcode = inbarcode } }); |
| | | |
| | | //写入子表 |
| | | for (int i = 0; i < arra.Count; i++) |
| | |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入开报工记录表 |
| | | sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date) |
| | | values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date } }); |
| | | sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date,inbarcode) |
| | | values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date,@inbarcode)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date, inbarcode = inbarcode } }); |
| | | |
| | | //写入子表 |
| | | for (int i = 0; i < arra.Count; i++) |
| | |
| | | //回写工单表合格数量、不良数量 |
| | | //sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } }); |
| | | |
| | | //写入ERP入库单 |
| | | |
| | | //判断是否末道工序完工报工(自动关闭工单及工序任务) |
| | | //list = AutosCloseOrder.AutosColseOrderReport(list,mesordercode, partcode, stepseq,stepcode,reportqty,ngqty); |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工, 收料提交] |
| | | public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string remarks, string username) |
| | | public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inbarcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string remarks, string username) |
| | | { |
| | | var sql = ""; |
| | | string[] arra1 = new string[] { }; |
| | |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入外协记录主表 |
| | | sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date) |
| | | values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } }); |
| | | sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date,inbarcode) |
| | | values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date, inbarcode = inbarcode } }); |
| | | |
| | | //写入外协记录子表 |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入外协记录主表 |
| | | sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date) |
| | | values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } }); |
| | | sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date,inbarcode) |
| | | values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date, inbarcode = inbarcode } }); |
| | | |
| | | //写入外协记录子表 |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | |
| | | //回写工单表合格数量、不良数量 |
| | | //sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } }); |
| | | |
| | | ////写入ERP入库单 |
| | | |
| | | //判断是否末道工序完工报工(自动关闭工单及工序任务) |
| | | //list = AutosCloseOrder.AutosColseOrderReport(list, mesordercode, partcode, stepseq, stepcode, sqty, ngqty); |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工,工序检验扫码获取任务信息] |
| | | public static ToMessage MesOrderStepCheckSearch(string orderstepqrcode) |
| | | |
| | | |
| | | #region[工序检验扫码获取任务信息] |
| | | public static ToMessage MesOrderStepCheckSearch(string orderstepqrcode, string checktype) |
| | | { |
| | | var sql = ""; |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | Dictionary<string, object> list = new Dictionary<string, object>(); |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | //通过扫描二维码信息查找任务信息 |
| | | sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,S.stepcode,S.stepname |
| | | sql = @"select A.wo_code,A.good_qty,M.partcode,M.partname,M.partspec,M.stocktype_code,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 |
| | |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | return mes; |
| | | if (decimal.Parse(data.Rows[0]["good_qty"].ToString()) > 0) |
| | | { |
| | | //获取绑定的质检方案、抽样方式、样本数 |
| | | sql = @"select code as checkstandcode,name as checkstandname,sampmethod,sampscare |
| | | from TStepCheckStandard |
| | | where (PATINDEX('%,' + RTRIM(@partcode) + ',%',',' + suitpart + ',')>0 or PATINDEX('%,' + RTRIM(@stocktype_code) + ',%',',' + suitpart + ',')>0) |
| | | and checktype=@checktype and stepcode=@stepcode "; |
| | | dynamicParams.Add("@partcode", data.Rows[0]["partcode"].ToString());//物料编码 |
| | | dynamicParams.Add("@stepcode", stepcode);//工序编码 |
| | | dynamicParams.Add("@stocktype_code", data.Rows[0]["stocktype_code"].ToString());//存货类型编码 |
| | | dynamicParams.Add("@checktype", checktype);//检验类型 |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0) |
| | | { |
| | | list.Add("labcont", data); |
| | | list.Add("chekstand", data1); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = list; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前产品【" + data.Rows[0]["partname"].ToString() + "】,对应工序【" + data.Rows[0]["stepname"].ToString() + "】,未指定质检方案!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序任务无报工产出!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | #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[生产开报工,工序检验根据检验标准获取检验项目列表] |
| | | #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 |
| | | //质检方案编码获取检验项 |
| | | sql = @"select A.stepcheckitem_seq, B.code,B.name,A.required,A.numberjudge,A.unit,A.decimalnum, |
| | | A.standvalue,A.uppervalue,A.lowervalue,A.stepcheckitem_desc |
| | | 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); |
| | | where A.stepstaned_code=@checkstandcode |
| | | order by A.stepcheckitem_seq"; |
| | | dynamicParams.Add("@checkstandcode", checkstandcode);//质检方案编码 |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前质检方案无检验项!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工,工序检验提交保存] |
| | | public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkusercode, string checktypecode, string checkresult, string checkdescr, string checkqty, string username, List<StepCheck> json) |
| | | #region[工序检验,提交] |
| | | public static ToMessage SaveMesOrderStepCheckItem(string wocode, string partcode, string stepcode, string checkstandcode, string check_type, string sampmethod, string qualitystatus, string labqty, string sampleqty, string goodqty, string ngqty, string checkitemcont, string username) |
| | | { |
| | | var sql = ""; |
| | | string[] arra = new string[] { }; |
| | | string[] arra1 = new string[] { }; |
| | | List<object> list = new List<object>(); |
| | | string checktypename = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | string date = DateTime.Now.ToString(); //获取系统时间 |
| | | |
| | | string datetime = DateTime.Now.ToString(); //获取系统时间 |
| | | //获取检验项目信息 |
| | | JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(checkitemcont); |
| | | list.Clear(); |
| | | switch (checktypecode) |
| | | |
| | | //写入检验记录主表 |
| | | sql = @"insert into TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_typename,sampmethod,check_result,check_qty,good_qty,ng_qty,lm_user,lm_date) |
| | | values(@wo_code,@partcode,@step_code,@checkstaned_code,@check_user,@check_type,@check_typename,@sampmethod,@check_result,@check_qty,@good_qty,@ng_qty,@lm_user,@lm_date)"; |
| | | switch (check_type) |
| | | { |
| | | case "FirstCheck": |
| | | checktypename = "首检"; |
| | |
| | | default: |
| | | break; |
| | | } |
| | | //写入工序检验记录主表 |
| | | sql = @"insert into TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_typename,check_result,check_descr,check_qty,lm_user,lm_date) |
| | | values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkusercode,@checktypecode,@checktypename,@checkresult,@checkdescr,@check_qty,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkusercode = checkusercode, checktypecode = checktypecode, checktypename = checktypename, checkresult = checkresult, checkdescr = checkdescr, check_qty = checkqty, lm_user = username, lm_date = date } }); |
| | | //写入工序检验记录子表 |
| | | //获取主表最大ID |
| | | sql = @"select ISNULL(IDENT_CURRENT('TStepCheckRecord')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | for (int i = 0; i < json.Count; i++) |
| | | list.Add(new |
| | | { |
| | | sql = @"insert into TStepCheckRecordSub(m_id,checkitem_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 } }); |
| | | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo_code = wocode, |
| | | partcode = partcode, |
| | | step_code = stepcode, |
| | | checkstaned_code = checkstandcode, |
| | | check_user = username, |
| | | check_type = check_type, |
| | | check_typename = checktypename, |
| | | sampmethod = sampmethod, |
| | | check_result = qualitystatus, |
| | | check_qty = decimal.Parse(sampleqty), |
| | | good_qty = decimal.Parse(goodqty), |
| | | ng_qty = decimal.Parse(ngqty), |
| | | lm_user = username, |
| | | lm_date = datetime |
| | | } |
| | | }); |
| | | //写入检验记录子表 |
| | | for (int j = 0; j < arra.Count; j++) |
| | | { |
| | | sql = @"insert into TStepCheckRecordSub(m_id,checknum,checkitem_seq,checkitem_code,checkitem_name,checkitem_descr,check_value,check_result,lm_user,lm_date) |
| | | values(CONVERT(INT,IDENT_CURRENT('TStepCheckRecord')),@checknum,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_value,@check_result,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | checknum = arra[j]["checknum"].ToString(), |
| | | checkiem_seq = arra[j]["checkiem_seq"].ToString(), |
| | | checkitem_code = arra[j]["checkitem_code"].ToString(), |
| | | checkitem_name = arra[j]["checkitem_name"].ToString(), |
| | | checkitem_descr = arra[j]["checkitem_descr"].ToString(), |
| | | check_value = arra[j]["check_value"].ToString(), |
| | | check_result = arra[j]["check_result"].ToString(), |
| | | lm_user = username, |
| | | lm_date = datetime |
| | | } |
| | | }); |
| | | } |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "检验成功!"; |
| | | mes.Message = "操作成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "检验失败!"; |
| | | mes.Message = "操作失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | #region[MES工单批量关闭查询] |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[生产入库条码补打] |
| | | public static ToMessage ProductInHouseLabCode(string ordercode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取末道工序报工条码数据 |
| | | sql = @"select * from( |
| | | select A.inbarcode,A.wo_code,P.partcode,P.partname,P.partspec, |
| | | A.good_qty,U.username,A.lm_date |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | inner join TMateriel_Info P on A.materiel_code=P.partcode |
| | | inner join TUser U on A.lm_user=U.usercode |
| | | where A.style='B' and S.isend='Y' and A.good_qty>0 |
| | | union all |
| | | select A.inbarcode,A.wo_code,P.partcode,P.partname,P.partspec, |
| | | A.sqty as sqty,U.username,A.lm_date |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | inner join TMateriel_Info P on A.materiel_code=P.partcode |
| | | inner join TUser U on A.lm_user=U.usercode |
| | | where A.style='S' and S.isend='Y' and A.sqty>0 |
| | | ) as AA where AA.wo_code=@ordercode"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | 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 ProductInHouseWkshopOrder(string ordertype, string wkshopcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (ordertype == "Y") //有源单 |
| | | { |
| | | sql = @"select distinct AA.ordercode from ( |
| | | select A.m_po as ordercode |
| | | from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step B on A.wo_code=B.wo_code |
| | | inner join TK_Wrk_Record S on B.wo_code=S.wo_code and B.step_code=S.step_code |
| | | where S.style='B' and B.isend='Y' and A.m_po<>'' and S.good_qty>0 and S.good_qty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode |
| | | union all |
| | | select A.m_po as ordercode |
| | | from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step B on A.wo_code=B.wo_code |
| | | inner join TK_Wrk_OutRecord S on B.wo_code=S.wo_code and B.step_code=S.step_code |
| | | where S.style='S' and B.isend='Y' and A.m_po<>'' and S.sqty>0 and S.sqty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode |
| | | ) as AA"; |
| | | } |
| | | if (ordertype == "N") |
| | | { |
| | | sql = @"select distinct AA.ordercode from ( |
| | | select A.wo_code as ordercode |
| | | from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step B on A.wo_code=B.wo_code |
| | | inner join TK_Wrk_Record S on B.wo_code=S.wo_code and B.step_code=S.step_code |
| | | where S.style='B' and B.isend='Y' and A.m_po='' and S.good_qty>0 and S.good_qty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode |
| | | union all |
| | | select A.wo_code as ordercode |
| | | from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step B on A.wo_code=B.wo_code |
| | | inner join TK_Wrk_OutRecord S on B.wo_code=S.wo_code and B.step_code=S.step_code |
| | | where S.style='S' and B.isend='Y' and A.m_po='' and S.sqty>0 and S.sqty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode |
| | | ) as AA"; |
| | | } |
| | | |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | 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 ProductInHouseOrderSearch(string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec, string startorderdate, string endorderdate) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and AA.wkshp_code=@wkshopcode "; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | } |
| | | if (erpordercode != "" && erpordercode != null) |
| | | { |
| | | search += "and AA.m_po like '%'+@erpordercode+'%' "; |
| | | dynamicParams.Add("@erpordercode", erpordercode); |
| | | } |
| | | if (mesordercode != "" && mesordercode != null) |
| | | { |
| | | search += "and AA.wo_code like '%'+@mesordercode+'%' "; |
| | | dynamicParams.Add("@mesordercode", mesordercode); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | | search += "and AA.partcode like '%'+@partcode+'%' "; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | } |
| | | if (partname != "" && partname != null) |
| | | { |
| | | search += "and AA.partname like '%'+@partname+'%' "; |
| | | dynamicParams.Add("@partname", partname); |
| | | } |
| | | if (partspec != "" && partspec != null) |
| | | { |
| | | search += "and AA.partspec like '%'+@partspec+'%' "; |
| | | dynamicParams.Add("@partspec", partspec); |
| | | } |
| | | if (startorderdate != "" && startorderdate != null) |
| | | { |
| | | search += "and AA.lm_date between @startorderdate and @endorderdate "; |
| | | dynamicParams.Add("@opencheckdate", startorderdate + " 00:00:00"); |
| | | dynamicParams.Add("@endorderdate", endorderdate + " 23:59:59"); |
| | | } |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select * from( |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname, |
| | | E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | inner join TK_Wrk_Man M on S.wo_code=M.wo_code |
| | | inner join TMateriel_Info P on M.materiel_code=P.partcode |
| | | left join TKimp_Ewo E on M.sourceid=E.id |
| | | left join T_Sec_Stck K on E.stck_code=K.code |
| | | where A.style='B' and S.isend='Y' and A.good_qty>0 |
| | | union all |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname, |
| | | E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | inner join TK_Wrk_Man M on S.wo_code=M.wo_code |
| | | inner join TMateriel_Info P on M.materiel_code=P.partcode |
| | | left join TKimp_Ewo E on M.sourceid=E.id |
| | | left join T_Sec_Stck K on E.stck_code=K.code |
| | | where A.style='S' and S.isend='Y' and A.sqty>0 |
| | | ) as AA where 1=1 " + search; |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.count = total; |
| | | 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 ProductInHouseOrderCodeSearch(string rightcode) |
| | | { |
| | | try |
| | | { |
| | | mes = SeachEncodeJob.EncodingSeach(rightcode); |
| | | 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 ProductInHouseOrderSeave(string username, JObject obj) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | var dynamicParams1 = new DynamicParameters(); |
| | | try |
| | | { |
| | | string sub = obj["sub"].ToString();//明细 |
| | | string subsum = obj["subsum"].ToString();//汇总 |
| | | //获取报工明细 |
| | | JArray sub_arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(sub); |
| | | //获取汇总 |
| | | JArray subsum_arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(subsum); |
| | | |
| | | //回写报工记录主表、工单工序表已入库数量、写入MES库存表 |
| | | for (int i = 0; i < sub_arra.Count; i++) |
| | | { |
| | | if (sub_arra[i]["style"].ToString() == "B") |
| | | { |
| | | //回写报工记录主表的入库数量 |
| | | sql = @"update TK_Wrk_Record set inhouseqty=inhouseqty+@stinhouseqty where inbarcode=@inbarcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()), |
| | | inbarcode = sub_arra[i]["inbarcode"].ToString() |
| | | } |
| | | }); |
| | | } |
| | | if (sub_arra[i]["style"].ToString() == "S") |
| | | { |
| | | //回写外协收料记录主表的入库数量 |
| | | sql = @"update TK_Wrk_OutRecord set inhouseqty=inhouseqty+@stinhouseqty where inbarcode=@inbarcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()), |
| | | inbarcode = sub_arra[i]["inbarcode"].ToString() |
| | | } |
| | | }); |
| | | } |
| | | //回写工单工序表末道工序已入库数量 |
| | | sql = @"update TK_Wrk_Step set inhouseqty=inhouseqty+@stinhouseqty where wo_code=@wo_code and step_code=@step_code and isend='Y'"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()), |
| | | wo_code = sub_arra[i]["wo_code"].ToString(), |
| | | step_code = sub_arra[i]["step_code"].ToString() |
| | | } |
| | | }); |
| | | //写入MES库存表 |
| | | sql = @"insert into TK_WMS_Stock(labcode,materiel_code,storehouse_code,qty,lm_user,lm_date) |
| | | values(@labcode,@materiel_code,@storehouse_code,@qty,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | labcode=sub_arra[i]["inbarcode"].ToString(), |
| | | materiel_code = sub_arra[i]["partcode"].ToString(), |
| | | storehouse_code = sub_arra[i]["stockcode"].ToString(), |
| | | qty =decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()), |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | //写MES入库记录主表 |
| | | sql = @"insert into TK_WMS_Inwh_Main(docu_typecode,hbillno,hsoucenillnoid,hsoucenillno,saleorderid,saleordercode,status,wkshpcode,lm_user,lm_date) |
| | | values(@docu_typecode,@hbillno,@hsoucenillnoid,@hsoucenillno,@saleorderid,@saleordercode,@status,@wkshpcode,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | docu_typecode="1202", |
| | | hbillno= obj["head"]["hbillno"].ToString(), |
| | | hsoucenillnoid= obj["head"]["sourceVoucherId"].ToString(), |
| | | hsoucenillno = obj["head"]["sourceVoucherCode"].ToString(), |
| | | saleorderid = obj["head"]["saleOrderId"].ToString(), |
| | | saleordercode = obj["head"]["saleOrderCode"].ToString(), |
| | | status = "NEW", |
| | | wkshpcode = obj["head"]["wkshpcode"].ToString(), |
| | | lm_user = username, |
| | | lm_date= DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | |
| | | //获取ERP入库表sql |
| | | DataTable dt = DapperHelper.lissql("h_p_MesInErpProductWareHous"); |
| | | //写入ERP入库记录主表 |
| | | sql = @"" + dt.Rows[0]["cname"].ToString() + ""; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | code = obj["head"]["hbillno"].ToString(), |
| | | sourceVoucherId = obj["head"]["sourceVoucherId"].ToString(), |
| | | sourceVoucherCode = obj["head"]["sourceVoucherCode"].ToString(), |
| | | saleOrderId = obj["head"]["saleOrderId"].ToString(), |
| | | saleOrderCode = obj["head"]["saleOrderCode"].ToString(), |
| | | rdDirectionFlag = obj["head"]["rdDirectionFlag"].ToString(), |
| | | makerid = obj["head"]["makerid"].ToString(), |
| | | maker = obj["head"]["maker"].ToString(), |
| | | accountingyear = obj["head"]["accountingyear"].ToString(), |
| | | VoucherYear = obj["head"]["VoucherYear"].ToString(), |
| | | VoucherPeriod = obj["head"]["VoucherPeriod"].ToString(), |
| | | ManufactureOrderCode = obj["head"]["ManufactureOrderCode"].ToString(), |
| | | idbusitype = obj["head"]["idbusitype"].ToString(), |
| | | iddepartment = obj["head"]["iddepartment"].ToString(), |
| | | idrdstyle = obj["head"]["idrdstyle"].ToString(), |
| | | idwarehouse = obj["head"]["idwarehouse"].ToString(), |
| | | voucherState = obj["head"]["voucherState"].ToString(), |
| | | idvouchertype = obj["head"]["idvouchertype"].ToString(), |
| | | voucherdate = obj["head"]["voucherdate"].ToString(), |
| | | madedate = obj["head"]["madedate"].ToString(), |
| | | createdtime = obj["head"]["createdtime"].ToString(), |
| | | DataSource = obj["head"]["DataSource"].ToString(), |
| | | |
| | | } |
| | | }); |
| | | //写入ERP、MES入库记录子表 |
| | | for (int j = 0; j < subsum_arra.Count; j++) |
| | | { |
| | | //写入ERP入库记录子表 |
| | | sql = @"" + dt.Rows[1]["cname"].ToString() + ""; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | code = subsum_arra[j]["code"].ToString(), |
| | | arrivalQuantity = subsum_arra[j]["arrivalQuantity"].ToString(), |
| | | quantity = subsum_arra[j]["quantity"].ToString(), |
| | | compositionQuantity = subsum_arra[j]["compositionQuantity"].ToString(), |
| | | baseQuantity = subsum_arra[j]["baseQuantity"].ToString(), |
| | | sourceVoucherId = subsum_arra[j]["sourceVoucherId"].ToString(), |
| | | sourceVoucherCode = subsum_arra[j]["sourceVoucherCode"].ToString(), |
| | | sourceVoucherDetailId = subsum_arra[j]["sourceVoucherDetailId"].ToString(), |
| | | idsourcevouchertype = subsum_arra[j]["idsourcevouchertype"].ToString(), |
| | | saleOrderId = subsum_arra[j]["saleOrderId"].ToString(), |
| | | saleOrderCode = subsum_arra[j]["saleOrderCode"].ToString(), |
| | | saleOrderDetailId = subsum_arra[j]["saleOrderDetailId"].ToString(), |
| | | ManufactureOrderId = subsum_arra[j]["ManufactureOrderId"].ToString(), |
| | | ManufactureOrderCode = subsum_arra[j]["ManufactureOrderCode"].ToString(), |
| | | ManufactureOrderDetailId = subsum_arra[j]["ManufactureOrderDetailId"].ToString(), |
| | | idbusiTypeByMergedFlow = subsum_arra[j]["idbusiTypeByMergedFlow"].ToString(), |
| | | idinventory = subsum_arra[j]["idinventory"].ToString(), |
| | | idbaseunit = subsum_arra[j]["idbaseunit"].ToString(), |
| | | idunit = subsum_arra[j]["idunit"].ToString(), |
| | | idwarehouse = subsum_arra[j]["idwarehouse"].ToString(), |
| | | SourceVoucherIdByMergedFlow = subsum_arra[j]["SourceVoucherIdByMergedFlow"].ToString(), |
| | | SourceVoucherCodeByMergedFlow = subsum_arra[j]["SourceVoucherCodeByMergedFlow"].ToString(), |
| | | SourceVoucherDetailIdByMergedFlow = subsum_arra[j]["SourceVoucherDetailIdByMergedFlow"].ToString(), |
| | | idsourceVoucherTypeByMergedFlow = subsum_arra[j]["idsourceVoucherTypeByMergedFlow"].ToString(), |
| | | createdtime = subsum_arra[j]["createdtime"].ToString(), |
| | | DataSource = subsum_arra[j]["DataSource"].ToString() |
| | | } |
| | | }); |
| | | //写入MES入库记录子表 |
| | | sql = @"insert into TK_WMS_Inwh_Sub(hbillno,rownumber,materiel_code,storehouse_code,qty) |
| | | values(@hbillno,@rownumber,@materiel_code,@storehouse_code,@qty)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | hbillno = obj["head"]["hbillno"].ToString(), |
| | | rownumber = subsum_arra[j]["rownumber"].ToString(), |
| | | materiel_code = subsum_arra[j]["materiel_code"].ToString(), |
| | | storehouse_code = subsum_arra[j]["warehouse"].ToString(), |
| | | qty = decimal.Parse(subsum_arra[j]["quantity"].ToString()) |
| | | } |
| | | }); |
| | | } |
| | | //更新单据流水号 |
| | | List<object> list1 = SeachEncodeJob.StrEncodingUpdate(obj["head"]["rightcode"].ToString(), obj["head"]["incbit"].ToString()); |
| | | list.Add(list1[0]); |
| | | 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 |
| | | } |
| | | } |