| | |
| | | if (paydatestartdate != "" && paydatestartdate != null) |
| | | { |
| | | search += "and A.paydate between @paydatestartdate and @paydateenddate "; |
| | | dynamicParams.Add("@paydatestartdate", paydatestartdate); |
| | | dynamicParams.Add("@paydatestartdate", paydatestartdate+" 00:00:00"); |
| | | dynamicParams.Add("@paydateenddate", paydateenddate + " 23:59:59"); |
| | | } |
| | | if (createstartdate != "" && createstartdate != null) |
| | | { |
| | | search += "and A.createdate between @paydatestartdate and @paydateenddate "; |
| | | search += "and A.createdate between @createstartdate and @createenddate "; |
| | | dynamicParams.Add("@createstartdate", createstartdate); |
| | | dynamicParams.Add("@createenddate", createenddate + " 23:59:59"); |
| | | } |
| | |
| | | try |
| | | { |
| | | //获取车间下拉框数据 |
| | | sql = @"select R.code,R.name from TMateriel_Info A |
| | | sql = @"select R.code,R.name,A.default_route from TMateriel_Info A |
| | | inner join TMateriel_Route M on A.partcode=M.materiel_code |
| | | inner join TFlw_Rout R on M.route_code=R.code |
| | | where A.partcode=@partcode "; |
| | |
| | | from TFlw_Rtdt A |
| | | left join TStep B on A.step_code=B.stepcode |
| | | left join TFlw_Rout C on A.rout_code=C.code |
| | | where A.first_choke='Y' and A.rout_code=@routecode |
| | | where A.rout_code=@routecode |
| | | and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'"; |
| | | list.Add(new |
| | | { |
| | |
| | | from TFlw_Rtdt A |
| | | left join TStep B on A.step_code=B.stepcode |
| | | left join TFlw_Rout C on A.rout_code=C.code |
| | | where A.first_choke='Y' and A.rout_code='R001' |
| | | where A.rout_code=@routecode |
| | | and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'"; |
| | | list.Add(new |
| | | { |
| | |
| | | planenddate = planenddate, |
| | | status = "ALLO", //派发 |
| | | username = username, |
| | | routecode= routecode, |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | //查询生产订单表数据 |
| | | sql = @"select * from TKimp_Ewo where wo=@m_po"; |
| | | dynamicParams.Add("@m_po", m_po); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//以下单数量 |
| | | if ((relse_qty - decimal.Parse(orderqty)) == 0) //全部撤销 订单状态回写未开始,已下单数量为0 |
| | | if (m_po != "" && m_po != null) |
| | | { |
| | | //回写订单表状态及已下单数量 |
| | | sql = @"update TKimp_Ewo set status='NEW',relse_qty=0 where wo=@m_po"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po } }); |
| | | } |
| | | else |
| | | { |
| | | //回写订单表状态及已下单数量 |
| | | sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty where wo=@m_po"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } }); |
| | | //查询生产订单表数据 |
| | | sql = @"select * from TKimp_Ewo where wo=@m_po"; |
| | | dynamicParams.Add("@m_po", m_po); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//以下单数量 |
| | | if ((relse_qty - decimal.Parse(orderqty)) == 0) //全部撤销 订单状态回写未开始,已下单数量为0 |
| | | { |
| | | //回写订单表状态及已下单数量 |
| | | sql = @"update TKimp_Ewo set status='NEW',relse_qty=0 where wo=@m_po"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po } }); |
| | | } |
| | | else |
| | | { |
| | | //回写订单表状态及已下单数量 |
| | | sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty where wo=@m_po"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } }); |
| | | } |
| | | } |
| | | //删除工单工序表 |
| | | sql = @"delete TK_Wrk_Step where wo_code=@wocode"; |
| | |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序二维码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | |
| | | if (ordercode != "" && ordercode == null) //工单号不为空,工序号为空 |
| | | if (ordercode != "" && ordercode != null) //工单号不为空,工序号为空 |
| | | { |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | } |
| | | if (ordercode != "" && ordercode != "") //工单号不为空,工序号不为空 |
| | | if (ordercode != "" && stepcode != "") //工单号不为空,工序号不为空 |
| | | { |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | } |
| | | } |
| | | 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; |
| | | //} |
| | | if (stepcode != "") |
| | | { |
| | | //查找当前工序属性 |
| | | sql = @"select * from TStep where TStep where stepcode=@stepcode"; |
| | | sql = @"select * from TStep where stepcode=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序二维码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | if (ordercode != "" && ordercode == null) //工单号不为空,工序号为空 |
| | | if (ordercode != "" && ordercode != null) //工单号不为空,工序号为空 |
| | | { |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | } |
| | | if (ordercode != "" && ordercode != "") //工单号不为空,工序号不为空 |
| | | if (ordercode != "" && stepcode != "") //工单号不为空,工序号不为空 |
| | | { |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | } |
| | | } |
| | | 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; |
| | | //} |
| | | if (stepcode != "") |
| | | { |
| | | //查找当前工序属性 |
| | | sql = @"select * from TStep where TStep where stepcode=@stepcode"; |
| | | sql = @"select * from TStep where stepcode=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "二维码信息错误,请扫描工序任务卡或者报工打印标签!"; |
| | | mes.Message = "请扫描工序条码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | |
| | | try |
| | | { |
| | | //班组获取人员列表 |
| | | sql = @"select usercode,username from TUser where usergroup_code=@stepcode"; |
| | | sql = @"select usercode,username from TUser where usergroup_code=@usergroupcode and is_delete<>'1'"; |
| | | dynamicParams.Add("@usergroupcode", usergroupcode); |
| | | 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 MesOrderSelectUser(string usercode) |
| | | { |
| | | string sql = ""; |
| | | string search = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (usercode != "" && usercode != null) //工单号不为空,工序号为空 |
| | | { |
| | | search += "and usercode=@usercode "; |
| | | dynamicParams.Add("@usercode", usercode); |
| | | } |
| | | //班组获取人员列表 |
| | | sql = @"select usercode,username from TUser where is_delete<>'1' "+search; |
| | | dynamicParams.Add("@usercode", usercode); |
| | | 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 MesOrderStepSelectWX(string orderstepqrcode) |
| | | { |
| | | string sql = ""; |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | | { |
| | | string[] arra = orderstepqrcode.Split(';'); |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "二维码信息为空!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //获取外协下拉框 |
| | | sql = @"select C.code,C.name from TFlw_Rteqp A |
| | | 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); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | |
| | | //判断是否有报工记录(有:修改 无:新增) |
| | | sql = @"select * from TK_Wrk_Record where wo_code=@wo_code and step_code=@step_code and style='B'"; |
| | | dynamicParams.Add("@wo_code", mesordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | //修改报工记录 |
| | | sql = @"update TK_Wrk_Record set good_qty=good+@reportqty,ng_qty=ng_qty+@ngqty |
| | | lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode and step_code=@stepcode"; |
| | | sql = @"update TK_Wrk_Record set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty, |
| | | lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode and step_code=@stepcode and style='B'"; |
| | | list.Add(new { str = sql, parm = new { reportqty = decimal.Parse(reportqty), ngqty = decimal.Parse(ngqty), mesordercode = mesordercode, stepcode = stepcode, username = username, CreateDate = date } }); |
| | | //写入子表 |
| | | for (int i = 0; i < arra.Length; i++) |
| | |
| | | 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 != "" || badcode != null) |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.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 != "" || badcode != null) |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | |
| | | string date = DateTime.Now.ToString(); //获取系统时间 |
| | | list.Clear(); |
| | | //判断是否有发料记录(有(同工单+工序+外协供方修改) 无:新增) |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wxcode and style='F'"; |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wx_code and style='F'"; |
| | | dynamicParams.Add("@wo_code", mesordercode); |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | dynamicParams.Add("@wx_code", wxcode); |
| | |
| | | { |
| | | //修改发料记录 |
| | | sql = @"update TK_Wrk_OutRecord set fqty=fqty+@fqty,lm_user=@username,lm_date=@CreateDate |
| | | where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code"; |
| | | where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='F'"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, fqty = decimal.Parse(fqty), username = username, CreateDate = date } }); |
| | | //写入子表 |
| | | sql = @"insert into TK_Wrk_RecordSub(m_id,wx_code,out_person,out_time,fqty,syle,lm_user,lm_date) |
| | | values(@m_id,@wx_code,@out_person,@out_time,@fqty,@lm_user,@lm_date)"; |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date) |
| | | values(@m_id,@wx_code,@out_person,@out_time,@fqty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } }); |
| | | } |
| | | else |
| | |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'F', fqty = fqty, lm_user = username, lm_date = date } }); |
| | | |
| | | //写入子表 |
| | | sql = @"insert into TK_Wrk_RecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date) |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date) |
| | | values(@m_id,@wx_code,@out_person,@out_time,@fqty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } }); |
| | | } |
| | |
| | | |
| | | list.Clear(); |
| | | //判断是否有收料记录(有:(同工单+工序+外协供方修改) 无:新增) |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wxcode and style='F'"; |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wx_code and style='S'"; |
| | | dynamicParams.Add("@wo_code", mesordercode); |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | dynamicParams.Add("@wx_code", wxcode); |
| | |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | //修改外协记录主表 |
| | | sql = @"update TK_Wrk_OutRecord set sqty=sqty+@sqty,ng_qty=@ngqty,lm_user=@username,lm_date=@CreateDate |
| | | where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code"; |
| | | sql = @"update TK_Wrk_OutRecord set sqty=sqty+@sqty,ng_qty=ng_qty+@ngqty,lm_user=@username,lm_date=@CreateDate |
| | | where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='S'"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } }); |
| | | //写入外协记录子表 |
| | | sql = @"insert into TK_Wrk_RecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,syle,lm_user,lm_date) |
| | | values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@lm_user,@lm_date)"; |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } }); |
| | | |
| | | if (badcode != "" || badcode != null) |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@stepcode,@style,@lm_user,@lm_date)"; |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = 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_RecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | if (badcode != "" || badcode != null) |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@stepcode,@style,@lm_user,@lm_date)"; |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | } |