1.ERP订单关闭增加单据id关联
2.MES工单关闭增加源单id关联
3.增加订单反关闭功能
4.增加工单反关闭功能
| | |
| | | [HttpPost] |
| | | public JsonResult ClosedErpOrder(string erporderid, string erpordercode) |
| | | { |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | var token =HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = WorkOrderBLL.ClosedErpOrder(erporderid, erpordercode, us); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[ERP订单反关闭] |
| | | /// <summary> |
| | | /// ERP订单反关闭 |
| | | /// </summary> |
| | | /// <param name="erporderid">订单id</param> |
| | | /// <param name="erpordercode">订单号</param> |
| | | /// <returns></returns> |
| | | [Route(template: "ReverseClosedErpOrder")] |
| | | [HttpPost] |
| | | public JsonResult ReverseClosedErpOrder(string erporderid, string erpordercode) |
| | | { |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = WorkOrderBLL.ReverseClosedErpOrder(erporderid, erpordercode, us); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = WorkOrderBLL.MesOrderBitchClosedSeave(us, wocodelist); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单反关闭提交] |
| | | /// <summary> |
| | | /// MES工单反关闭提交 |
| | | /// </summary> |
| | | /// <param name="wocodelist">工单号数组</param> |
| | | /// <returns></returns> |
| | | [Route(template: "MesOrderBitchReverseClosedSeave")] |
| | | [HttpPost] |
| | | public JsonResult MesOrderBitchReverseClosedSeave([FromBody] string[] wocodelist) |
| | | { |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = WorkOrderBLL.MesOrderBitchReverseClosedSeave(us, wocodelist); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | |
| | | /// <summary> |
| | | /// 生产执行,报工审核列表数据查询接口 |
| | | /// </summary> |
| | | /// <param name="reviewstatus">审核状态</param> |
| | | /// <param name="wkshopcode">车间编码</param> |
| | | /// <param name="wo_code">工单编号</param> |
| | | /// <param name="partnumber">产品编码</param> |
| | |
| | | /// <returns></returns> |
| | | [Route(template: "MesOrderStepReportVerifySearch")] |
| | | [HttpGet] |
| | | public JsonResult MesOrderStepReportVerifySearch(string wkshopcode=null, string wo_code = null, string partnumber = null, string partname = null, string partspec = null,string stepname=null, string reportuser = null, string reportdate = null, int page = 0, int rows = 0, string prop = null, string order = null) |
| | | public JsonResult MesOrderStepReportVerifySearch(string reviewstatus=null, string wkshopcode=null, string wo_code = null, string partnumber = null, string partname = null, string partspec = null,string stepname=null, string reportuser = null, string reportdate = null, int page = 0, int rows = 0, string prop = null, string order = null) |
| | | { |
| | | string reportdateopendate = ""; //报工开始时间 |
| | | string reportdateclosedate = ""; //报工结束时间 |
| | |
| | | } |
| | | int startNum = rows * (page - 1) + 1; //起始记录rowNum |
| | | int endNum = rows * page; //结束记录 rowNum |
| | | mes = WorkOrderBLL.MesOrderStepReportVerifySearch(wkshopcode,wo_code, partnumber, partname, partspec,stepname,reportuser, reportdateopendate, reportdateclosedate, startNum, endNum, prop, order); |
| | | mes = WorkOrderBLL.MesOrderStepReportVerifySearch(reviewstatus,wkshopcode, wo_code, partnumber, partname, partspec,stepname,reportuser, reportdateopendate, reportdateclosedate, startNum, endNum, prop, order); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产执行,报工弃审数据提交] |
| | | /// <summary> |
| | | /// 生产执行,报工弃审数据提交 |
| | | /// </summary> |
| | | /// <param name="id">报工记录id</param> |
| | | /// <param name="steptype">工序类型</param> |
| | | /// <returns></returns> |
| | | [Route(template: "MesOrderStepReportNotVerifySeave")] |
| | | [HttpPost] |
| | | public JsonResult MesOrderStepReportNotVerifySeave(string id,string steptype) |
| | | { |
| | | var token = HttpContext.Request.Headers["Token"].ToString(); |
| | | User us = JwtTools.Denocode(token.ToString()); |
| | | mes = WorkOrderBLL.MesOrderStepReportNotVerifySeave(us, id, steptype); |
| | | return Json(mes); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[ERP订单反关闭] |
| | | public static ToMessage ReverseClosedErpOrder(string erporderid, string erpordercode, User us) |
| | | { |
| | | return WorkOrderDAL.ReverseClosedErpOrder(erporderid, erpordercode, us); |
| | | } |
| | | #endregion |
| | | |
| | | #region[ERP订单删除] |
| | | public static ToMessage DeleteErpOrder(string erporderid, string erpordercode, User us) |
| | | { |
| | |
| | | public static ToMessage MesOrderBitchClosedSeave(User us, string[] wocodelist) |
| | | { |
| | | return WorkOrderDAL.MesOrderBitchClosedSeave(us,wocodelist); |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单批量反关闭提交] |
| | | public static ToMessage MesOrderBitchReverseClosedSeave(User us, string[] wocodelist) |
| | | { |
| | | return WorkOrderDAL.MesOrderBitchReverseClosedSeave(us, wocodelist); |
| | | } |
| | | #endregion |
| | | |
| | |
| | | |
| | | |
| | | #region[生产执行,报工审核列表数据查询接口] |
| | | public static ToMessage MesOrderStepReportVerifySearch(string wkshopcode, string wo_code, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderStepReportVerifySearch(string reviewstatus, string wkshopcode, string wo_code, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | { |
| | | return WorkOrderDAL.MesOrderStepReportVerifySearch(wkshopcode,wo_code, partnumber, partname, partspec, stepname, reportuser, reportdateopendate, reportdateclosedate, startNum, endNum, prop, order); |
| | | return WorkOrderDAL.MesOrderStepReportVerifySearch(reviewstatus,wkshopcode, wo_code, partnumber, partname, partspec, stepname, reportuser, reportdateopendate, reportdateclosedate, startNum, endNum, prop, order); |
| | | } |
| | | #endregion |
| | | |
| | |
| | | return WorkOrderDAL.MesOrderStepReportVerifySeave(us,json); |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产执行,报工弃审数据提交] |
| | | public static ToMessage MesOrderStepReportNotVerifySeave(User us, string id,string steptype) |
| | | { |
| | | return WorkOrderDAL.MesOrderStepReportNotVerifySeave(us, id, steptype); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | |
| | | { |
| | | string erpordercode = group.erpordercode; |
| | | int count = 1; |
| | | foreach (var model in obj.Where(s => s.erpordercode==erpordercode).ToList()) |
| | | foreach (var model in obj.Where(s => s.erpordercode == erpordercode).ToList()) |
| | | { |
| | | //获取当前最大工单号 |
| | | sql = @"select isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0) as worknumb |
| | |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | sql = @"select * from TK_Wrk_Man where m_po=@erpordercode and status<> 'CLOSED'"; |
| | | sql = @"select * from TK_Wrk_Man where m_po=@erpordercode and sourceid=@sourceid"; |
| | | dynamicParams.Add("@erpordercode", erpordercode); |
| | | dynamicParams.Add("@sourceid", erporderid); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = "当前订单有下达未关闭的MES工单,订单不允许关闭,请先删除或关闭相关工单!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | //关闭订单 |
| | | sql = @"update TKimp_Ewo set status='CLOSED' where wo=@wo and id=@erporderid"; |
| | | // 使用LINQ和lambda表达式来转换wo_code字段的值为逗号隔开的字符串数组 |
| | | string[] result = data.AsEnumerable().Select(row => "" + row.Field<string>("wo_code") + "").ToArray(); |
| | | //关闭工序任务 |
| | | sql = @"update TK_Wrk_Step set status='CLOSED',closebeforestatus=status where wo_code in @wocode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo = erpordercode, |
| | | erporderid = erporderid |
| | | wocode = result |
| | | } |
| | | }); |
| | | //关闭工单 |
| | | sql = @"update TK_Wrk_Man set status='CLOSED',closebeforestatus=status where m_po=@erpordercode and sourceid=@sourceid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | erpordercode = erpordercode, |
| | | sourceid = erporderid |
| | | } |
| | | }); |
| | | } |
| | | //关闭订单 |
| | | sql = @"update TKimp_Ewo set status='CLOSED',closebeforestatus=status where wo=@wo and id=@erporderid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo = erpordercode, |
| | | erporderid = erporderid |
| | | } |
| | | }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | 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[ERP订单反关闭] |
| | | public static ToMessage ReverseClosedErpOrder(string erporderid, string erpordercode, User us) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | |
| | | sql = @"select * from TK_Wrk_Man where m_po=@erpordercode and sourceid=@sourceid"; |
| | | dynamicParams.Add("@erpordercode", erpordercode); |
| | | dynamicParams.Add("@sourceid", erporderid); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | // 使用LINQ和lambda表达式来转换wo_code字段的值为逗号隔开的字符串数组 |
| | | string[] result = data.AsEnumerable().Select(row => "" + row.Field<string>("wo_code") + "").ToArray(); |
| | | //关闭工序任务 |
| | | sql = @"update TK_Wrk_Step set status=closebeforestatus where wo_code in @ordercode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | ordercode = result |
| | | } |
| | | }); |
| | | //关闭工单 |
| | | sql = @"update TK_Wrk_Man set status=closebeforestatus where m_po=@erpordercode and sourceid=@sourceid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | erpordercode = erpordercode, |
| | | sourceid = erporderid |
| | | } |
| | | }); |
| | | } |
| | | //反关闭订单 |
| | | sql = @"update TKimp_Ewo set status=closebeforestatus where wo=@wo and id=@erporderid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo = erpordercode, |
| | | erporderid = erporderid |
| | | } |
| | | }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "反关闭", "反关闭了订单:" + erpordercode, us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "订单反关闭成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = "订单反关闭失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | |
| | | var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources |
| | | from TK_Wrk_Man A |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sourceid=W.id |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.torg_code |
| | | left join TSecStck D on A.stck_code=D.code |
| | |
| | | for (int i = 0; i < wocodelist.Length; i++) |
| | | { |
| | | //关闭工单对应工序任务 |
| | | sql = @"update TK_Wrk_Step set status='CLOSED' where wo_code in @wocode"; |
| | | sql = @"update TK_Wrk_Step set status='CLOSED',closebeforestatus=status where wo_code in @wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocodelist } }); |
| | | //回写工单表状态为(关闭) |
| | | sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate where wo_code in @wocode"; |
| | | sql = @"update TK_Wrk_Man set status='CLOSED',closebeforestatus=status,closeuser=@username,closedate=@closedate where wo_code in @wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocodelist, username = us.usercode, closedate = DateTime.Now.ToString() } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | |
| | | 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[MES工单批量反关闭提交] |
| | | public static ToMessage MesOrderBitchReverseClosedSeave(User us, string[] wocodelist) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | for (int i = 0; i < wocodelist.Length; i++) |
| | | { |
| | | //关闭工单对应工序任务 |
| | | sql = @"update TK_Wrk_Step set status=closebeforestatus where wo_code in @wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocodelist } }); |
| | | //回写工单表状态为(关闭) |
| | | sql = @"update TK_Wrk_Man set status=closebeforestatus,closeuser=@username,closedate=@closedate where wo_code in @wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocodelist, username = us.usercode, closedate = DateTime.Now.ToString() } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "反关闭", "关闭了工单:" + string.Join(",", wocodelist), us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "工单反关闭成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = "工单反关闭失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | #region[生产执行,报工审核列表数据查询接口] |
| | | public static ToMessage MesOrderStepReportVerifySearch(string wkshopcode, string wo_code, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderStepReportVerifySearch(string reviewstatus, string wkshopcode, string wo_code, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (reviewstatus != "" && reviewstatus != null) |
| | | { |
| | | search += "and AA.verify=@reviewstatus "; |
| | | dynamicParams.Add("@reviewstatus", reviewstatus); |
| | | } |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and AA.wkshp_code=@wkshopcode "; |
| | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "报工审核", "自制报工记录id:" + string.Join(",", json.zdata), us.usertype); |
| | | LogHelper.DbOperateLog(us.usercode, "报工审核", "外协收料记录id:" + string.Join(",", json.wdata), us.usertype); |
| | | if (json.zdata.Count > 0) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "报工审核", "自制报工记录id:" + string.Join(",", json.zdata), us.usertype); |
| | | } |
| | | if (json.wdata.Count > 0) |
| | | { |
| | | LogHelper.DbOperateLog(us.usercode, "报工审核", "外协收料记录id:" + string.Join(",", json.wdata), us.usertype); |
| | | } |
| | | 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 MesOrderStepReportNotVerifySeave(User us, string id, string steptype) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (steptype == "Z")//自制工序 |
| | | { |
| | | //回写报工记录主表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_Record set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where id=@id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } }); |
| | | //回写报工记录子表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_RecordSub set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where m_id=@id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } }); |
| | | } |
| | | if (steptype == "W")//外协工序 |
| | | { |
| | | //回写外协记录主表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_OutRecord set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where id=@id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } }); |
| | | //回写外协记录子表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_OutRecordSub set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where m_id=@id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | if (steptype == "Z") |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "报工弃审", "自制报工记录id:" + string.Join(",", id), us.usertype); |
| | | } |
| | | if (steptype == "W") |
| | | { |
| | | LogHelper.DbOperateLog(us.usercode, "报工弃审", "外协收料记录id:" + string.Join(",", id), us.usertype); |
| | | } |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "审核成功!"; |