| | |
| | | #endregion |
| | | |
| | | #region[ERP订单下达] |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode,string deptcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string idTopInventory, string TopInventoryCode, string TopInventoryName, string saleOrderDeliveryDate, string paystartdate, string payenddate, string clerkuser, User us) |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode, string deptcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string idTopInventory, string TopInventoryCode, string TopInventoryName, string saleOrderDeliveryDate, string paystartdate, string payenddate, string clerkuser, User us) |
| | | { |
| | | var sql = ""; |
| | | string orderstatus = "", isstep = ""; //工单状态、是否绑定工艺 |
| | |
| | | wo_code = wo, |
| | | wotype = "PO", |
| | | status = orderstatus, //"NEW" |
| | | dept_code= deptcode, |
| | | dept_code = deptcode, |
| | | wkshp_code = wkshopcode, |
| | | plan_qty = cdqty + (decimal.Parse(markqty) - sumqty), //末单下单数量=切分数量+(下单数量-累计切分下单数量) |
| | | stck_code = warehousecode, |
| | |
| | | wo_code = wo, |
| | | wotype = "PO", |
| | | status = orderstatus, //"NEW" |
| | | dept_code=deptcode, |
| | | dept_code = deptcode, |
| | | wkshp_code = wkshopcode, |
| | | plan_qty = cdqty, |
| | | stck_code = warehousecode, |
| | |
| | | step_code = data0.Rows[j]["step_code"].ToString(), |
| | | route_code = data0.Rows[j]["default_route"].ToString(), |
| | | stepprice = decimal.Parse(data0.Rows[j]["unprice"].ToString() == "" || data0.Rows[j]["unprice"].ToString() == null ? "0" : data0.Rows[j]["unprice"].ToString()), |
| | | plan_quantity = cdqty + (decimal.Parse(markqty) - sumqty), //末单下单数量=切分数量+(下单数量-累计切分下单数量), |
| | | plan_qty = cdqty + (decimal.Parse(markqty) - sumqty), //末单下单数量=切分数量+(下单数量-累计切分下单数量), |
| | | plan_quantity = cdqty, |
| | | plan_qty = cdqty, |
| | | ratio = 0, |
| | | status = orderstatus, |
| | | isbott = data0.Rows[j]["first_choke"].ToString(), |
| | |
| | | wo_code = wo, |
| | | wotype = "PO", |
| | | status = orderstatus, //"NEW" |
| | | dept_code=model.deptcode, |
| | | dept_code = model.deptcode, |
| | | wkshp_code = model.wkshopcode, |
| | | plan_qty = decimal.Parse(model.erpqty), //订单数量 |
| | | stck_code = model.warehousecode, |
| | | sbid = model.sbid, |
| | | materiel_code = model.partcode, |
| | | route_code=data0.Rows.Count<=0?"": data0.Rows[0]["default_route"].ToString(), |
| | | route_code = data0.Rows.Count <= 0 ? "" : data0.Rows[0]["default_route"].ToString(), |
| | | sourceid = model.erporderid, |
| | | m_po = model.erpordercode, |
| | | username = us.usercode, |
| | |
| | | data_sources = "ERP", |
| | | isstep = isstep, //是否关联工序 "N" |
| | | clerkuser = model.clerkuser, //销售订单业务员 |
| | | idTopInventory =model.idTopInventory, |
| | | idTopInventory = model.idTopInventory, |
| | | TopInventoryCode = model.TopInventoryCode, |
| | | TopInventoryName = model.TopInventoryName |
| | | } |
| | |
| | | seq = data0.Rows[i]["seq"].ToString(), |
| | | step_code = data0.Rows[i]["step_code"].ToString(), |
| | | route_code = data0.Rows[i]["default_route"].ToString(), |
| | | stepprice = decimal.Parse(data0.Rows[i]["unprice"].ToString()==""|| data0.Rows[i]["unprice"].ToString() ==null? "0":data0.Rows[i]["unprice"].ToString()), |
| | | stepprice = decimal.Parse(data0.Rows[i]["unprice"].ToString() == "" || data0.Rows[i]["unprice"].ToString() == null ? "0" : data0.Rows[i]["unprice"].ToString()), |
| | | plan_quantity = decimal.Parse(model.erpqty), //订单数量 |
| | | plan_qty = decimal.Parse(model.erpqty), //订单数量 |
| | | ratio = 0, |
| | |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.idTopInventory,A.TopInventoryCode,A.TopInventoryName,A.route_code,B.default_route,R.name as route_name,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,A.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources,A.isstep,A.clerkuser, |
| | | B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6,A.printcount |
| | | B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6,A.printcount,W.memo,W.bomsubspec |
| | | from TK_Wrk_Man A |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.idTopInventory,A.TopInventoryCode,A.TopInventoryName,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,S.laborbad_qty,S.materielbad_qty, |
| | | B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6 |
| | | B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6,W.memo,W.bomsubspec |
| | | from TK_Wrk_Man A |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid |
| | | left join (select wo_code,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty from TK_Wrk_Step where (laborbad_qty+materielbad_qty)>0 group by wo_code) S on A.wo_code=S.wo_code |
| | |
| | | materiel_code = json.partcode, |
| | | route_code = route_code, |
| | | sourceid = json.sourceid == "" ? null : json.sourceid, //无源单时赋值NULL |
| | | saleOrderCode=json.saleordercode, |
| | | saleOrderCode = json.saleordercode, |
| | | m_po = json.sourcewo, |
| | | saleOrderDeliveryDate = json.deliverydate, |
| | | plan_startdate = json.paystartdate, |
| | |
| | | stepprice = json.WorkListSub[i].stepprice, |
| | | plan_quantity = json.woqty, |
| | | plan_qty = json.WorkListSub[i].sumqty, |
| | | ratio=json.WorkListSub[i].ratio, |
| | | ratio = json.WorkListSub[i].ratio, |
| | | status = json.wostatus, |
| | | isbott = json.WorkListSub[i].isbott, |
| | | isend = json.WorkListSub[i].isend, |
| | |
| | | stepprice = json.WorkListSub[i].stepprice, |
| | | plan_quantity = json.woqty, |
| | | plan_qty = json.WorkListSub[i].sumqty, |
| | | ratio=json.WorkListSub[i].ratio, |
| | | ratio = json.WorkListSub[i].ratio, |
| | | status = json.wostatus, |
| | | isbott = json.WorkListSub[i].isbott, |
| | | isend = json.WorkListSub[i].isend, |
| | |
| | | |
| | | if (worksteplist[i].data_sources == "ERP") //数据来源ERP |
| | | { |
| | | |
| | | |
| | | //查询当前工单可修改数量=订单总数-已下达工单总数 |
| | | sql = @"select isnull(plan_qty,0) as plan_qty from TK_Wrk_Man |
| | | where sourceid=@sourceid and m_po=@sourcewo and wo_code=@wocode"; |
| | |
| | | |
| | | // 向字典中添加数据 |
| | | dict.Add("canupdate_qty", canupdate_qty); |
| | | dict.Add("stepdata", data1); |
| | | dict.Add("stepdata", data1); |
| | | // 将字典添加到列表中 |
| | | dir.Add(dict); |
| | | mes.code = "200"; |
| | |
| | | materiel_code = json[i].partcode, |
| | | route_code = route_code, |
| | | sourceid = json[i].sourceid == "" ? null : json[i].sourceid, //无源单时赋值NULL |
| | | saleOrderCode=json[i].saleordercode, |
| | | saleOrderCode = json[i].saleordercode, |
| | | m_po = json[i].sourcewo, |
| | | saleOrderDeliveryDate = json[i].deliverydate, |
| | | plan_startdate = json[i].paystartdate, |
| | |
| | | stepprice = json[i].WorkListSub[j].stepprice, |
| | | plan_quantity = json[i].woqty, |
| | | plan_qty = json[i].WorkListSub[j].sumqty, |
| | | ratio=json[i].WorkListSub[j].ratio, |
| | | ratio = json[i].WorkListSub[j].ratio, |
| | | status = json[i].wostatus, |
| | | isbott = json[i].WorkListSub[j].isbott, |
| | | isend = json[i].WorkListSub[j].isend, |
| | |
| | | materiel_code = json[i].partcode, |
| | | route_code = route_code, |
| | | sourceid = json[i].sourceid == "" ? null : json[i].sourceid, //无源单时赋值NULL |
| | | saleOrderCode=json[i].saleordercode, |
| | | saleOrderCode = json[i].saleordercode, |
| | | m_po = json[i].sourcewo, |
| | | saleOrderDeliveryDate = json[i].deliverydate, |
| | | plan_startdate = json[i].paystartdate, |
| | |
| | | stepprice = json[i].WorkListSub[j].stepprice, |
| | | plan_quantity = json[i].woqty, |
| | | plan_qty = json[i].WorkListSub[j].sumqty, |
| | | ratio=json[i].WorkListSub[j].ratio, |
| | | ratio = json[i].WorkListSub[j].ratio, |
| | | status = json[i].wostatus, |
| | | isbott = json[i].WorkListSub[j].isbott, |
| | | isend = json[i].WorkListSub[j].isend, |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单批量查找历史引用最新工序信息] |
| | | public static ToMessage MesOrderNewStepListContent(List<BatchProcess> list, User us) |
| | | { |
| | | var sql = ""; |
| | | List<Dictionary<object, object>> dir = new List<Dictionary<object, object>>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | dynamic dynObj = JObject.Parse(us.mesSetting); |
| | | bool route = dynObj.route; |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | if (route) //工艺路线版 |
| | | { |
| | | Dictionary<object, object> dict = new Dictionary<object, object>(); |
| | | //MES工单查找历史引用最新工序信息 |
| | | sql = @"select S.wo_code,S.seq,S.step_code as stepcode,T.stepname as stepname,S.stepprice,S.isbott,S.isend,S.ratio |
| | | from TK_Wrk_Step S |
| | | inner join ( |
| | | select top 1 A.wo_code,A.route_code from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.route_code=S.route_code |
| | | where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode and A.route_code=@routecode |
| | | order by A.lm_date desc |
| | | ) as W on S.wo_code=W.wo_code and S.route_code=W.route_code |
| | | left join TStep T on S.step_code=T.stepcode |
| | | order by S.seq"; |
| | | dynamicParams.Add("@wkshopcode", list[i].wkshopcode); |
| | | dynamicParams.Add("@partcode", list[i].partcode); |
| | | dynamicParams.Add("@routecode", list[i].routecode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | // 向字典中添加数据 |
| | | dict.Add("partcode", list[i].partcode); |
| | | dict.Add("stepdata", data); |
| | | // 将字典添加到列表中 |
| | | dir.Add(dict); |
| | | } |
| | | else |
| | | { |
| | | Dictionary<object, object> dict = new Dictionary<object, object>(); |
| | | //MES工单查找历史引用最新工序信息 |
| | | sql = @"select S.wo_code,S.seq,S.step_code as stepcode,T.stepname as stepname,S.stepprice,S.isbott,S.isend,S.ratio |
| | | from TK_Wrk_Step S |
| | | inner join ( |
| | | select top 1 A.wo_code from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code |
| | | where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode |
| | | order by A.lm_date desc |
| | | ) as W on S.wo_code=W.wo_code |
| | | left join TStep T on S.step_code=T.stepcode |
| | | order by S.seq"; |
| | | dynamicParams.Add("@wkshopcode", list[i].wkshopcode); |
| | | dynamicParams.Add("@partcode", list[i].partcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | // 向字典中添加数据 |
| | | dict.Add("partcode", list[i].partcode); |
| | | dict.Add("stepdata", data); |
| | | // 将字典添加到列表中 |
| | | dir.Add(dict); |
| | | } |
| | | } |
| | | mes.code = "200"; |
| | | mes.count = dir.Count; |
| | | mes.data = dir; |
| | | mes.message = "查询成功!"; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单查看工单SOP] |
| | | public static ToMessage MesOrderSopSearch(string wocode, string materielcode) |
| | | { |
| | |
| | | { |
| | | wocode = wocodelist, |
| | | status = "ALLO", |
| | | distributionuser=us.usercode, |
| | | distributiontime= DateTime.Now.ToString() |
| | | distributionuser = us.usercode, |
| | | distributiontime = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | //更新工序任务表状态 |
| | |
| | | |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(自制)] |
| | | public static ToMessage MesOrderStepSearch(string wkshopcode, string wocode,string orderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderStepSearch(string wkshopcode, string wocode, string orderno, string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | } |
| | | if (ordercode != "" && stepcode != "") //工单号不为空,工序号不为空 |
| | | if (saorderno != "" && saorderno != "") //工单号不为空,工序号不为空 |
| | | { |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | |
| | | search += "and B.m_po like '%'+@orderno+'%' "; |
| | | dynamicParams.Add("@orderno", orderno); |
| | | } |
| | | if (saorderno != "" && saorderno != null) |
| | | { |
| | | search += "and B.saleOrderCode like '%'+@saorderno+'%' "; |
| | | dynamicParams.Add("@saorderno", saorderno); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | | search += "and M.partcode like '%'+@partcode+'%' "; |
| | |
| | | dynamicParams.Add("@partspec", partspec); |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.id,A.status,B.wkshp_code,T.torg_name as wkshp_name,A.wo_code,B.m_po,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | sql = @"select A.id,A.status,B.wkshp_code,T.torg_name as wkshp_name,A.wo_code,B.m_po,B.saleOrderCode,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_quantity,A.plan_qty,A.good_qty,A.ng_qty,A.laborbad_qty,A.materielbad_qty,B.lm_date, |
| | | M.priuserdefnvc1,M.priuserdefnvc2,M.priuserdefnvc3,M.priuserdefnvc4,M.priuserdefnvc5,M.priuserdefnvc6 |
| | | from TK_Wrk_Step A |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(外协)] |
| | | public static ToMessage MesOrderWxStepSearch(string wkshopcode, string wocode, string orderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderWxStepSearch(string wkshopcode, string wocode, string orderno, string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | |
| | | search += "and B.m_po like '%'+@orderno+'%' "; |
| | | dynamicParams.Add("@orderno", orderno); |
| | | } |
| | | if (saorderno != "" && saorderno != null) |
| | | { |
| | | search += "and B.saleOrderCode like '%'+@saorderno+'%' "; |
| | | dynamicParams.Add("@saorderno", saorderno); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | | search += "and M.partcode like '%'+@partcode+'%' "; |
| | |
| | | dynamicParams.Add("@partspec", partspec); |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.id,A.status,B.wkshp_code,T.torg_name as wkshp_name,A.wo_code,B.m_po,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | sql = @"select A.id,A.status,B.wkshp_code,T.torg_name as wkshp_name,A.wo_code,B.m_po,B.saleOrderCode,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_quantity,A.plan_qty,A.good_qty,A.ng_qty, |
| | | (select isnull(sum(fqty),0) as fqty from TK_Wrk_OutRecord where wo_code=A.wo_code and step_code=A.step_code and style='F') as fqty, |
| | | A.laborbad_qty,A.materielbad_qty,A.plan_startdate,A.plan_enddate,B.lm_date, |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(不良)] |
| | | public static ToMessage MesOrderNgStepSearch(string wkshopcode, string wocode, string orderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderNgStepSearch(string wkshopcode, string wocode, string orderno, string saorderno, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | |
| | | search += "and B.m_po like '%'+@orderno+'%' "; |
| | | dynamicParams.Add("@orderno", orderno); |
| | | } |
| | | if (saorderno != "" && saorderno != null) |
| | | { |
| | | search += "and B.saleOrderCode like '%'+@saorderno+'%' "; |
| | | dynamicParams.Add("@saorderno", saorderno); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | | search += "and M.partcode like '%'+@partcode+'%' "; |
| | |
| | | dynamicParams.Add("@partspec", partspec); |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.id,B.wkshp_code,T.torg_name as wkshp_name,A.wo_code,B.m_po,M.partcode,M.partname,M.partspec,A.seq,A.isend, |
| | | sql = @"select A.id,B.wkshp_code,T.torg_name as wkshp_name,A.wo_code,B.saleOrderCode,B.m_po,M.partcode,M.partname,M.partspec,A.seq,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_quantity,A.plan_qty,A.good_qty,A.ng_qty,A.laborbad_qty,A.materielbad_qty,B.lm_date, |
| | | M.priuserdefnvc1,M.priuserdefnvc2,M.priuserdefnvc3,M.priuserdefnvc4,M.priuserdefnvc5,M.priuserdefnvc6 |
| | | from TK_Wrk_Step A |
| | |
| | | try |
| | | { |
| | | //1.根据工单+工序查找当前工序是否首道工序 |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status, |
| | | sql = @"select A.wo_code,M.m_po,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status, |
| | | A.plan_quantity,A.plan_qty,A.good_qty,A.ng_qty,A.laborbad_qty,A.materielbad_qty,A.isbott,A.isend |
| | | from TK_Wrk_Step A |
| | | left join TStep T on A.step_code=T.stepcode |
| | |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | rt.wo_code = data.Rows[0]["wo_code"].ToString(); //工单号 |
| | | rt.orderno = data.Rows[0]["m_po"].ToString(); //订单号 |
| | | rt.partnumber = data.Rows[0]["partcode"].ToString(); //产品编码 |
| | | rt.partname = data.Rows[0]["partname"].ToString(); //产品名称 |
| | | rt.partspec = data.Rows[0]["partspec"].ToString(); //产品规格 |
| | |
| | | rt.stepname = data.Rows[0]["stepname"].ToString(); //工序名称 |
| | | rt.stepdesc = data.Rows[0]["descr"].ToString(); //工序描述 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["plan_qty"].ToString()); //任务超产总数量 |
| | | rt.planquantity= decimal.Parse(data.Rows[0]["plan_quantity"].ToString()); //任务数量 |
| | | rt.planquantity = decimal.Parse(data.Rows[0]["plan_quantity"].ToString()); //任务数量 |
| | | rt.noreportqty = decimal.Parse(data.Rows[0]["good_qty"].ToString()); //报工数量 |
| | | rt.noputqty = decimal.Parse(data.Rows[0]["ng_qty"].ToString()); //不良数量 |
| | | string isend = data.Rows[0]["isend"].ToString();//末道工序 |
| | |
| | | else //不按序收发料 |
| | | { |
| | | mes = ScanStartReport.NoWXEncodingSeach(SelectType, wocode, stepcode); |
| | | } |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工,报工提交] |
| | | public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string stepprice, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser,string payrate, string taskqty, string startqty, string reportqty, List<ReportDefectList> defectobjs, string remarks, User us) |
| | | public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string stepprice, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser, string payrate, string taskqty, string startqty, string reportqty, List<ReportDefectList> defectobjs, string remarks, User us) |
| | | { |
| | | var sql = ""; |
| | | decimal ngqty = 0; |
| | |
| | | { |
| | | m_id = int.Parse(dt.Rows[0]["ID"].ToString()), |
| | | eqp_code = eqpcode, |
| | | payrate= payrate, |
| | | payrate = payrate, |
| | | report_person = reportuser, |
| | | report_date = date, |
| | | report_qty = reportqty, |
| | |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < groupedItems.Count; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } }); |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,usergroup_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@usergroup_code,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code,report_person=reportuser,usergroup_code= usergroupcode, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | m_id = int.Parse(dt.Rows[0]["ID"].ToString()), |
| | | eqp_code = eqpcode, |
| | | payrate= payrate, |
| | | payrate = payrate, |
| | | report_person = reportuser, |
| | | report_date = date, |
| | | report_qty = reportqty, |
| | |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < groupedItems.Count; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } }); |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,usergroup_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@usergroup_code,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, report_person=reportuser, usergroup_code =usergroupcode, remarks = remarks, style = "B", lm_user = us.usercode, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < groupedItems.Count; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } }); |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, report_person=inuser, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < groupedItems.Count; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } }); |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,report_person,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@report_person,@remarks,@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 = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, report_person=inuser, remarks = remarks, style = "S", lm_user = us.usercode, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | #region[生产执行,报工调整数据查询接口] |
| | | public static ToMessage MesOrderStepVerifySearch(string wkshopcode, string wo_code,string orderno, string partnumber, string partname, string partspec,string stepcode, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderStepVerifySearch(string wkshopcode, string wo_code, string orderno, string saorderno, string partnumber, string partname, string partspec, string stepcode, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | { |
| | | search += "and AA.m_po like '%'+@orderno+'%' "; |
| | | dynamicParams.Add("@orderno", orderno); |
| | | } |
| | | if (saorderno != "" && saorderno != null) |
| | | { |
| | | search += "and AA.saleOrderCode like '%'+@saorderno+'%' "; |
| | | dynamicParams.Add("@saorderno", saorderno); |
| | | } |
| | | if (partnumber != "" && partnumber != null) |
| | | { |
| | |
| | | // --------------查询指定自制报工外协收料数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select * from( |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.eqp_code,E.name as eqp_name, |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,M.saleOrderCode,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,A.style,k.isbott as first_choke,k.isend as last_choke,A.step_price,B.reckway,B.usergroup_code,G.usergroupname as usergroup_name, |
| | | B.report_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | |
| | | left join TGroup G on G.usergroupcode=B.usergroup_code |
| | | where A.style='B' and B.style='B' and M.status<>'CLOSED' and A.verify='N' |
| | | union all |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.wx_code as eqp_code,E.name as eqp_name, |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,M.saleOrderCode,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.wx_code as eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,A.style,k.isbott as first_choke,k.isend as last_choke,A.step_price,'person' as reckway,'' as usergroup_code,'' as usergroup_name, |
| | | B.in_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else //不按序 |
| | |
| | | //控制逻辑:当前工序报工调整-> (本道工序当前调整合格数+本道工序非当前报工合格总数)<下道工序报工总数(合格+不良+报废) ==不能小于下道报工总数 |
| | | list.Clear(); |
| | | //判断当前工序是自制工序还是外协工序 |
| | | if (json[0].flw_type.ToString() == "Z") |
| | | if (json[0].flw_type.ToString() == "Z") |
| | | { |
| | | |
| | | //查询当前报工工序非此次报工:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | |
| | | //查询当前报工工序非此次报工:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty |
| | | from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | |
| | | return mes; |
| | | } |
| | | } |
| | | if (json[0].flw_type.ToString() == "W") |
| | | if (json[0].flw_type.ToString() == "W") |
| | | { |
| | | //获取当前工序、供应商对应的总发料数量 |
| | | sql = @"select isnull(sum(fqty),0) as fqty |
| | |
| | | decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //当前末道工序非本次报工总数 |
| | | decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //当前末道工序非本次报工工废总数 |
| | | decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //当前末道工序非本次报工料废总数 |
| | | //获取当前末道工序收料总数量:本次修改收料数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数 |
| | | //获取当前末道工序收料总数量:本次修改收料数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数 |
| | | decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty; |
| | | //判断当前工序供应商收料总数>当前工序供应商对应发料数量 |
| | | if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString())) |
| | |
| | | |
| | | //回写对应的报工记录子表合格数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_RecordSub set report_qty=report_qty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty, |
| | | updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | report_person=@report_person,usergroup_code=@usergroup_code,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | where m_id=@m_id and id=@id and style='B'"; |
| | | list.Add(new |
| | | { |
| | |
| | | laborbad_qty = this_laborbad_dvalue, |
| | | materielbad_qty = this_materielbad_dvalue, |
| | | //bad_money = decimal.Parse(json[i].badmoney_dvalue), |
| | | report_person = json[0].usercode, |
| | | usergroup_code = json[0].groupcode, |
| | | updatereportuser = us.usercode, |
| | | updatereportdate = date |
| | | } |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | step_price=decimal.Parse(json[0].unprice), |
| | | step_price = decimal.Parse(json[0].unprice), |
| | | good_qty = decimal.Parse(json[0].report_dvalue), |
| | | ng_qty = this_ng_dvalue, |
| | | laborbad_qty = this_laborbad_dvalue, |
| | |
| | | { |
| | | //回写不良 |
| | | sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty, |
| | | updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | report_person=@report_person,usergroup_code=@usergroup_code,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='B'"; |
| | | list.Add(new |
| | | { |
| | |
| | | step_code = json[0].step_code, |
| | | ng_id = int.Parse(json[0].children[i].ng_id), |
| | | record_id = json[0].id, |
| | | report_person = json[0].usercode, |
| | | usergroup_code = json[0].groupcode, |
| | | updatereportuser = us.usercode, |
| | | updatereportdate = date |
| | | } |
| | |
| | | |
| | | //回写对应的外协记录子表收料数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty, |
| | | updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | out_person=@out_person,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | where m_id=@m_id and id=@id and style='S' and wx_code=@wx_code"; |
| | | list.Add(new |
| | | { |
| | |
| | | materielbad_qty = this_materielbad_dvalue, |
| | | wx_code = json[0].wxcode, |
| | | //bad_money = decimal.Parse(json[i].badmoney_dvalue), |
| | | out_person = json[0].usercode, |
| | | updatereportuser = us.usercode, |
| | | updatereportdate = date |
| | | } |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | step_price=decimal.Parse(json[0].unprice), |
| | | step_price = decimal.Parse(json[0].unprice), |
| | | good_qty = decimal.Parse(json[0].report_dvalue), |
| | | ng_qty = this_ng_dvalue, |
| | | laborbad_qty = this_laborbad_dvalue, |
| | |
| | | { |
| | | //回写不良 |
| | | sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty, |
| | | updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | report_person=@report_person,usergroup_code=@usergroup_code,updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='S'"; |
| | | list.Add(new |
| | | { |
| | |
| | | step_code = json[0].step_code, |
| | | ng_id = int.Parse(json[0].children[i].ng_id), |
| | | record_id = json[0].id, |
| | | report_person = json[0].usercode, |
| | | usergroup_code = json[0].groupcode, |
| | | updatereportuser = us.usercode, |
| | | updatereportdate = date |
| | | } |
| | |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "批量修改工价", "报工ID:" + string.Join(",",json.Select(bp => bp.id).ToArray())+",操作类型:"+ string.Join(",", json.Select(bp => bp.type).ToArray()), us.usertype); |
| | | LogHelper.DbOperateLog(us.usercode, "批量修改工价", "报工ID:" + string.Join(",", json.Select(bp => bp.id).ToArray()) + ",操作类型:" + string.Join(",", json.Select(bp => bp.type).ToArray()), us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "操作成功!"; |
| | |
| | | mes.data = null; |
| | | } |
| | | } |
| | | else |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | |
| | | |
| | | |
| | | #region[生产执行,报工审核列表数据查询接口] |
| | | public static ToMessage MesOrderStepReportVerifySearch(string reviewstatus, string wkshopcode, string wo_code, string orderno, 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 orderno, string saorderno, 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 = ""; |
| | |
| | | { |
| | | search += "and AA.m_po like '%'+@orderno+'%' "; |
| | | dynamicParams.Add("@orderno", orderno); |
| | | } |
| | | if (saorderno != "" && saorderno != null) |
| | | { |
| | | search += "and AA.saleOrderCode like '%'+@saorderno+'%' "; |
| | | dynamicParams.Add("@saorderno", saorderno); |
| | | } |
| | | if (partnumber != "" && partnumber != null) |
| | | { |
| | |
| | | // --------------查询指定自制报工外协收料数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select * from( |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.eqp_code,E.name as eqp_name, |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,M.saleOrderCode,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,B.reckway,B.usergroup_code,G.usergroupname as usergroup_name, |
| | | B.report_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | |
| | | left join TGroup G on G.usergroupcode=B.usergroup_code |
| | | where A.style='B' and B.style='B' and M.status<>'CLOSED' |
| | | union all |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.wx_code as eqp_code,E.name as eqp_name, |
| | | select A.id,B.id as sbid,A.wo_code,M.m_po,M.saleOrderCode,A.materiel_code as partnumber,P.partname,P.partspec,K.plan_quantity,K.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.wx_code as eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,'person' as reckway,'' as usergroup_code,'' as usergroup_name, |
| | | B.in_person as usercode, |
| | | STUFF((SELECT ',' + U.username |