| | |
| | | |
| | | |
| | | #region[组织架构,查询组织信息] |
| | | public static ToMessage STorgData(string storg_code, string storg_name) |
| | | public static ToMessage STorgData(string storg_code, string storg_name,string torgtype_code) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (torgtype_code != "" && torgtype_code != null) |
| | | { |
| | | search += "and T.torgtype_code=@torgtype_code "; |
| | | dynamicParams.Add("@torgtype_code", torgtype_code); |
| | | } |
| | | if (storg_code != "" && storg_code != null) |
| | | { |
| | | search += "and T.torg_code like '%'+@storg_code+'%' "; |
| | |
| | | search += "and T.torg_name like '%'+@storg_name+'%' "; |
| | | dynamicParams.Add("@storg_name", storg_name); |
| | | } |
| | | var sql = @"select T.id,T.parent_id,T.torg_code,T.torg_name,T.status,T.leve,T.torg_seq, |
| | | var sql = @"select T.id,T.parent_id,T.torg_code,T.torg_name,T.torgtype_code,Y.torgtype_name,T.status,T.leve,T.torg_seq, |
| | | T.lm_user as usercode,U.username,T.lm_date |
| | | from TOrganization T |
| | | left join TOrganType Y on T.torgtype_code=Y.torgtype_code |
| | | left join TUser U on T.lm_user=U.usercode |
| | | where 1=1" + search + " order by T.lm_date desc"; |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | #endregion |
| | | |
| | | #region[新增编辑组织架构] |
| | | public static ToMessage AddUpdateOrganization(string OrganCode, string OrganName, string leve, string parent_id, string storgcode, string torg_seq, string status, string OperType, User us) |
| | | public static ToMessage AddUpdateOrganization(string OrganCode, string OrganName, string leve, string parent_id, string storgcode,string torgtype_code, string torg_seq, string status, string OperType, User us) |
| | | { |
| | | string sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | return mes; |
| | | } |
| | | |
| | | sql = @"insert into TOrganization(parent_id,torg_code,torg_name,status,leve,torg_seq,lm_user,lm_date) |
| | | values(@parent_id,@torg_code,@torg_name,@status,@leve,@torg_seq,@lm_user,@lm_date)"; |
| | | sql = @"insert into TOrganization(parent_id,torg_code,torg_name,torgtype_code,status,leve,torg_seq,lm_user,lm_date) |
| | | values(@parent_id,@torg_code,@torg_name,@torgtype_code,@status,@leve,@torg_seq,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | parent_id = storgcode, |
| | | torg_code = OrganCode, |
| | | torg_name = OrganName, |
| | | torgtype_code= torgtype_code, |
| | | status = status, |
| | | leve = leve, |
| | | torg_seq = torg_seq, |
| | |
| | | } |
| | | |
| | | //修改当前组织数据 |
| | | sql = @"update TOrganization set parent_id=@parent_id,torg_name=@torg_name,leve=@leve,torg_seq=@torg_seq,lm_user=@lm_user,lm_date=@lm_date |
| | | sql = @"update TOrganization set parent_id=@parent_id,torg_name=@torg_name,torgtype_code=@torgtype_code,leve=@leve,torg_seq=@torg_seq,lm_user=@lm_user,lm_date=@lm_date |
| | | where torg_code=@torg_code"; |
| | | list.Add(new |
| | | { |
| | |
| | | parent_id = storgcode, |
| | | torg_code = OrganCode, |
| | | torg_name = OrganName, |
| | | torgtype_code= torgtype_code, |
| | | leve = leve, |
| | | torg_seq = torg_seq, |
| | | lm_user = us.usercode, |
| | |
| | | if (cont > 0) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "新增", "删除了组织:" + orgcode, us.usertype); |
| | | LogHelper.DbOperateLog(us.usercode, "删除", "删除了组织:" + orgcode, us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "删除操作成功!"; |
| | |
| | | else |
| | | { |
| | | //判断当前工艺路线是否有设置节拍工价(有设置,提示先删除节拍工价设置) |
| | | sql = @"select * from TPrteEqp_Stad where route_code=@routecode"; |
| | | sql = @"select * from TPrteStep_Price where route_code=@routecode"; |
| | | dynamicParams.Add("@routecode", routecode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | |
| | | } |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.id,A.stepcode,A.stepname,A.flwtype,A.enable,A.descr,U.username as lm_user,A.lm_date |
| | | var sql = @"select A.id,A.stepcode,A.stepname,A.flwtype,A.enable,A.is_eqp,A.descr,U.username as lm_user,A.lm_date |
| | | from TStep A |
| | | left join TUser U on A.lm_user=U.usercode |
| | | where A.is_delete<>'1' " + search; |
| | |
| | | #endregion |
| | | |
| | | #region[工序新增编辑] |
| | | public static ToMessage AddUpdateStep(string stepid, string stepcode, string stepname, string steptypecode, string enable, string description, User us, string operType) |
| | | public static ToMessage AddUpdateStep(string operType, User us, TFlw_Rteqp tflw_rteqp) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<object> list = new List<object>(); |
| | |
| | | if (operType == "Add") |
| | | { |
| | | sql = @"select * from TStep where stepcode=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | dynamicParams.Add("@stepcode", tflw_rteqp.stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //写入工序表 |
| | | sql = @"insert into TStep(stepcode,stepname,flwtype,enable,descr,lm_user,lm_date) |
| | | values(@stepcode,@stepname,@steptypecode,@enable,@description,@username,@CreateDate)"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | dynamicParams.Add("@stepname", stepname); |
| | | dynamicParams.Add("@steptypecode", steptypecode); |
| | | dynamicParams.Add("@enable", enable); |
| | | dynamicParams.Add("@description", description); |
| | | dynamicParams.Add("@username", us.usercode); |
| | | dynamicParams.Add("@CreateDate", DateTime.Now.ToString()); |
| | | int cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | stepcode = tflw_rteqp.stepcode, |
| | | stepname = tflw_rteqp.stepname, |
| | | steptypecode = tflw_rteqp.steptypecode, |
| | | enable = tflw_rteqp.enable, |
| | | description = tflw_rteqp.description, |
| | | username = us.usercode, |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | //写入工序关联设备表 |
| | | if (tflw_rteqp.children.Count > 0) |
| | | { |
| | | for (int i = 0; i < tflw_rteqp.children.Count; i++) |
| | | { |
| | | sql = @"insert into TFlw_Rteqp(eqp_code,step_code,style,lm_user,lm_date) |
| | | values(@eqp_code,@step_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | eqp_code = tflw_rteqp.children[i].eqpcode, |
| | | step_code = tflw_rteqp.children[i].stepcode, |
| | | style = tflw_rteqp.children[i].style, |
| | | lm_user = us.usercode, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | //标记物料表关联工艺路线标识 |
| | | sql = @"update TStep set is_eqp='Y' where stepcode=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { stepcode = tflw_rteqp.stepcode } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "新增", "新增了工序:" + stepcode, us.usertype); |
| | | LogHelper.DbOperateLog(us.usercode, "新增", "新增了工序:" + tflw_rteqp.stepcode, us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "新增操作成功!"; |
| | |
| | | if (operType == "Update") |
| | | { |
| | | list.Clear(); |
| | | //如果当前工序使用状态位N(未启用),需判断当前工序是否被工单引用 |
| | | if (enable == "N") |
| | | //如果当前工序使用状态位N(未启用) |
| | | if (tflw_rteqp.enable == "N") |
| | | { |
| | | var sql0 = @"select * from TK_Wrk_Step A where A.step_code=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql0, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | //需判断当前工序是否被工单引用 |
| | | sql = @"select * from TK_Wrk_Step A where A.step_code=@stepcode"; |
| | | dynamicParams.Add("@stepcode", tflw_rteqp.stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | |
| | | return mes; |
| | | } |
| | | } |
| | | //根据工序查找历史设备 |
| | | sql = @"select step_code as stepcode,eqp_code as eqpcode,style from TFlw_Rteqp where step_code=@stepcode"; |
| | | dynamicParams.Add("@stepcode", tflw_rteqp.stepcode); |
| | | var data = DapperHelper.select<StepEqpData>(sql, dynamicParams); |
| | | // 历史中有而提交中没有的元素(执行删除) |
| | | var inBNotInA = data.Where(b => !tflw_rteqp.children.Any(a => a.eqpcode == b.eqpcode)).ToList(); |
| | | for (int i = 0; i < inBNotInA.Count; i++) |
| | | { |
| | | //删除工序关联设备表 |
| | | sql = @"delete TFlw_Rteqp where step_code=@step_code and eqp_code=@eqp_code"; |
| | | list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code= inBNotInA[i].eqpcode } }); |
| | | //删除设备节拍工价表 |
| | | sql = @"delete TPrteEqp_Stad where step_code=@step_code and eqp_code=@eqp_code"; |
| | | list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code = inBNotInA[i].eqpcode } }); |
| | | } |
| | | // 提交中有而历史中没有的元素(执行写入) |
| | | var inANotInB = tflw_rteqp.children.Where(a => !data.Any(b => b.eqpcode == a.eqpcode)).ToList(); |
| | | for (int i = 0; i < inANotInB.Count; i++) |
| | | { |
| | | //写入工序关联设备表 |
| | | sql = @"insert into TFlw_Rteqp(eqp_code,step_code,style,lm_user,lm_date) |
| | | values(@eqp_code,@step_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | eqp_code = inANotInB[i].eqpcode, |
| | | step_code = inANotInB[i].stepcode, |
| | | style = inANotInB[i].style, |
| | | lm_user = us.usercode, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | if (tflw_rteqp.children.Count > 0) |
| | | { |
| | | //标记物料表关联工艺路线标识 |
| | | sql = @"update TStep set is_eqp='Y' where stepcode=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { stepcode = tflw_rteqp.stepcode } }); |
| | | } |
| | | if (tflw_rteqp.children.Count <= 0) |
| | | { |
| | | //标记物料表关联工艺路线标识 |
| | | sql = @"update TStep set is_eqp='N' where stepcode=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { stepcode = tflw_rteqp.stepcode } }); |
| | | } |
| | | sql = @"update TStep set stepname=@stepname,flwtype=@steptypecode,enable=@enable,descr=@description, |
| | | lm_user=@username,lm_date=@CreateDate where id=@stepid"; |
| | | list.Add(new { str = sql, parm = new { stepid = stepid, stepname = stepname, steptypecode = steptypecode, enable = enable, description = description, username = us.usercode, CreateDate = DateTime.Now.ToString() } }); |
| | | list.Add(new { str = sql, parm = new { stepid = tflw_rteqp.id, stepname = tflw_rteqp.stepname, steptypecode = tflw_rteqp.steptypecode, enable = tflw_rteqp.enable, description = tflw_rteqp.description, username = us.usercode, CreateDate = DateTime.Now.ToString() } }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "修改", "修改了工序:" + stepcode, us.usertype); |
| | | LogHelper.DbOperateLog(us.usercode, "修改", "修改了工序:" + tflw_rteqp.stepcode, us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.message = "修改操作成功!"; |
| | |
| | | try |
| | | { |
| | | list.Clear(); |
| | | //当前工序是否设置工价 |
| | | sql = @"select * from TPrteStep_Price A where A.step_code=@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.data = null; |
| | | return mes; |
| | | } |
| | | //当前工序是否关联工单 |
| | | sql = @"select * from TK_Wrk_Step A where A.step_code=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //删除工序关联工作站表 |
| | | sql = @"delete TFlw_Rteqp where step_code=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { stepcode = stepcode } }); |
| | | //删除工序 |
| | | sql = @"delete TStep where stepcode=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { stepcode = stepcode } }); |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[工序定义关联工作站查询] |
| | | public static ToMessage StepAssociationEqp(string stepcode, User us) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<StepEqp> list = new List<StepEqp>(); |
| | | try |
| | | { |
| | | //获取工作站集合(车间、外协供应商,包含已绑定工作站标识) |
| | | sql = @"select distinct T.torg_code as wksp_code,T.torg_name as wksp_name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag |
| | | from TOrganization T |
| | | left join( |
| | | select distinct A.eqp_code,B.torg_code as wksp_code from TFlw_Rteqp A |
| | | inner join TEqpInfo B on A.eqp_code=B.code |
| | | where A.step_code=@stepcode and B.enable='Y' |
| | | ) B on T.torg_code=B.wksp_code where T.torgtype_code='W' |
| | | UNION ALL |
| | | select distinct T.code as wksp_code,T.name as wksp_name,'W' as type,(case when B.customertype is null then 'N' else 'Y' end) flag |
| | | from TCustomerType T |
| | | left join( |
| | | select distinct A.eqp_code,B.customertype from TFlw_Rteqp A |
| | | inner join TCustomer B on A.eqp_code=B.code |
| | | where A.step_code=@stepcode |
| | | ) B on T.code=B.customertype"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < data.Rows.Count; i++) |
| | | { |
| | | StepEqp rout = new StepEqp(); |
| | | rout.code = data.Rows[i]["WKSP_CODE"].ToString(); |
| | | rout.name = data.Rows[i]["WKSP_NAME"].ToString(); |
| | | rout.type = data.Rows[i]["TYPE"].ToString(); |
| | | rout.flag = data.Rows[i]["FLAG"].ToString(); |
| | | rout.children = new List<StepEqpCn>(); |
| | | if (rout.type == "W") //外协供方 |
| | | { |
| | | //根据外协供方标识编码查找外协供方信息(包含已关联标识) |
| | | sql = @"select A.code,A.name,'W' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag |
| | | from TCustomer A |
| | | left join( |
| | | select distinct A.eqp_code from TFlw_Rteqp A |
| | | inner join TCustomer B on A.eqp_code=B.code |
| | | where A.step_code=@stepcode and B.customertype=@wxcode |
| | | ) B on A.code=B.eqp_code where A.customertype=@wxcode "; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | dynamicParams.Add("@wxcode", rout.code); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int k = 0; k < data0.Rows.Count; k++) |
| | | { |
| | | StepEqpCn cn = new StepEqpCn(); |
| | | cn.code = data0.Rows[k]["CODE"].ToString();//外协供方编码 |
| | | cn.name = data0.Rows[k]["NAME"].ToString();//外协供方名称 |
| | | cn.type = data0.Rows[k]["TYPE"].ToString();//工作站类型(E:设备 W:外协供方) |
| | | cn.flag = data0.Rows[k]["FLAG"].ToString();//关联标识 |
| | | rout.children.Add(cn); |
| | | } |
| | | list.Add(rout); |
| | | } |
| | | else |
| | | { |
| | | //根据车间编码查找设备(包含已关联标识) |
| | | sql = @"select A.code,A.name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag |
| | | from TEqpInfo A |
| | | left join( |
| | | select distinct A.eqp_code from TFlw_Rteqp A |
| | | inner join TEqpInfo B on A.eqp_code=B.code |
| | | where A.step_code=@stepcode and B.enable='Y' |
| | | ) B on A.code=B.eqp_code where A.torg_code=@wkspcode "; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | dynamicParams.Add("@wkspcode", data.Rows[i]["WKSP_CODE"].ToString()); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int j = 0; j < data0.Rows.Count; j++) |
| | | { |
| | | StepEqpCn cn = new StepEqpCn(); |
| | | cn.code = data0.Rows[j]["CODE"].ToString();//设备编码 |
| | | cn.name = data0.Rows[j]["NAME"].ToString();//设备名称 |
| | | cn.type = data0.Rows[j]["TYPE"].ToString();//工作站类型(E:设备 W:外协供方) |
| | | cn.flag = data0.Rows[j]["FLAG"].ToString();//关联标识 |
| | | rout.children.Add(cn); |
| | | } |
| | | list.Add(rout); |
| | | } |
| | | } |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |
| | | mes.data = list; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region [工序定义关联工作站提交] |
| | | public static ToMessage SaveStepAssociationEqp(string stepcode, User us, List<ObjectData> json) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | list.Clear(); |
| | | //根据工序查找历史设备 |
| | | sql = @"select step_code as stepcode,eqp_code as eqpcode,style from TFlw_Rteqp where step_code=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.select<StepEqpData>(sql, dynamicParams); |
| | | // 历史中有而提交中没有的元素(执行删除) |
| | | var inBNotInA = data.Where(b => !json.Any(a => a.code == b.eqpcode)).ToList(); |
| | | for (int i = 0; i < inBNotInA.Count; i++) |
| | | { |
| | | //删除工序关联设备表 |
| | | sql = @"delete TFlw_Rteqp where step_code=@step_code and eqp_code=@eqp_code"; |
| | | list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code = inBNotInA[i].eqpcode } }); |
| | | //删除设备节拍工价表 |
| | | sql = @"delete TPrteEqp_Stad where step_code=@step_code and eqp_code=@eqp_code"; |
| | | list.Add(new { str = sql, parm = new { step_code = inBNotInA[i].stepcode, eqp_code = inBNotInA[i].eqpcode } }); |
| | | } |
| | | // 提交中有而历史中没有的元素(执行写入) |
| | | var inANotInB = json.Where(a => !data.Any(b => b.eqpcode == a.code)).ToList(); |
| | | for (int i = 0; i < inANotInB.Count; i++) |
| | | { |
| | | //写入工序关联设备表 |
| | | sql = @"insert into TFlw_Rteqp(eqp_code,step_code,style,lm_user,lm_date) |
| | | values(@eqp_code,@step_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | eqp_code = inANotInB[i].code, |
| | | step_code = stepcode, |
| | | style = inANotInB[i].name, |
| | | lm_user = us.usercode, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | if (json.Count > 0) |
| | | { |
| | | //标记物料表关联工艺路线标识 |
| | | sql = @"update TStep set is_eqp='Y' where stepcode=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { stepcode = stepcode } }); |
| | | } |
| | | if (json.Count <= 0) |
| | | { |
| | | //标记物料表关联工艺路线标识 |
| | | sql = @"update TStep set is_eqp='N' where stepcode=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { stepcode = stepcode } }); |
| | | } |
| | | 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 |
| | | |
| | | |
| | | |
| | | #region[节拍工价,产品信息查询] |
| | |
| | | inner join TFlw_Rout B on A.route_code=B.code |
| | | where A.materiel_code=@partcode and B.is_delete<>'1' and A.is_delete<>'1'"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else //工序版 |
| | | { |
| | | //通过产品编码查找关联的工序信息 |
| | | sql = @"select A.step_seq,A.step_code,S.stepname as step_name,A.unprice,A.isbott,A.isend |
| | | sql = @"select A.step_seq as seq,A.step_code as code,S.stepname as name,A.unprice,A.isbott,A.isend,S.flwtype |
| | | from ( |
| | | select S.materiel_code,R.step_seq,S.step_code,S.unprice,R.isbott,R.isend from TPrteEqp_Stad S |
| | | select S.materiel_code,R.step_seq,S.step_code,S.unprice,R.isbott,R.isend from TPrteStep_Price S |
| | | inner join TMateriel_Step R on S.materiel_code=R.materiel_code and S.step_code=R.step_code |
| | | where S.materiel_code=@partcode |
| | | where S.route_code is null and S.materiel_code=@partcode |
| | | union all |
| | | select materiel_code,step_seq,step_code,'0' as unprice,isbott,isend from TMateriel_Step |
| | | where materiel_code=@partcode and materiel_code+step_code |
| | | not in(select materiel_code+step_code from TPrteEqp_Stad |
| | | where materiel_code=@partcode) |
| | | not in(select materiel_code+step_code from TPrteStep_Price |
| | | where route_code is null and materiel_code=@partcode) |
| | | ) as A |
| | | left join TStep S on A.step_code=S.stepcode"; |
| | | left join TStep S on A.step_code=S.stepcode |
| | | A.step_seq"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | var parents = DapperHelper.select<SubData>(sql, dynamicParams); |
| | | for (int i = 0; i < parents.Count; i++) |
| | | { |
| | | if (parents[i].flwtype == "Z") |
| | | { |
| | | //通过产品编码+工序编码查找对应设备信息 |
| | | sql = @"select A.eqp_code,E.name as eqp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice |
| | | from ( |
| | | select S.eqp_code,S.eqp_value,S.stand_value,S.cavity_qty,S.unprice from TPrteEqp_Stad S |
| | | inner join TMateriel_Step R on S.materiel_code=R.materiel_code and S.step_code=R.step_code |
| | | where S.materiel_code=@partcode and S.step_code=@stepcode and S.route_code is null |
| | | union all |
| | | select R.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Step S |
| | | inner join TFlw_Rteqp R on S.step_code=R.step_code |
| | | where S.materiel_code=@partcode and S.step_code=@stepcode and S.materiel_code+S.step_code+R.eqp_code |
| | | not in(select materiel_code+step_code+eqp_code from TPrteEqp_Stad |
| | | where materiel_code=@partcode and step_code=@stepcode and route_code is null) |
| | | ) as A |
| | | left join TEqpInfo E on A.eqp_code=E.code"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@stepcode", parents[i].code); |
| | | var children = DapperHelper.select<EqpSubData>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | else |
| | | { |
| | | //通过产品编码+工序编码查找对应外协供应商信息 |
| | | sql = @"select A.eqp_code,C.name as eqp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice |
| | | from ( |
| | | select S.eqp_code,S.eqp_value,S.stand_value,S.cavity_qty,S.unprice from TPrteEqp_Stad S |
| | | inner join TMateriel_Step R on S.materiel_code=R.materiel_code and S.step_code=R.step_code |
| | | where S.materiel_code=@partcode and S.step_code=@stepcode and S.route_code is null |
| | | union all |
| | | select R.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Step S |
| | | inner join TFlw_Rteqp R on S.step_code=R.step_code |
| | | where S.materiel_code=@partcode and S.step_code=@stepcode and S.materiel_code+S.step_code+R.eqp_code |
| | | not in(select materiel_code+step_code+eqp_code from TPrteEqp_Stad |
| | | where materiel_code=@partcode and step_code=@stepcode and route_code is null) |
| | | ) as A |
| | | left join TCustomer C on A.eqp_code=C.code"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@stepcode", parents[i].code); |
| | | var children = DapperHelper.select<EqpSubData>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | |
| | | } |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |
| | | mes.data = parents; |
| | | } |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | try |
| | | { |
| | | //通过工艺路线编码查找关联的工序信息 |
| | | sql = @"select A.step_seq,A.step_code,S.stepname as step_name,A.unprice,A.isbott,A.isend |
| | | sql = @"select A.step_seq as seq,A.step_code as code,S.stepname as name,A.unprice,A.isbott,A.isend,S.flwtype |
| | | from ( |
| | | select S.materiel_code,R.seq as step_seq,S.step_code,S.unprice,R.first_choke as isbott,R.last_choke as isend from TPrteEqp_Stad S |
| | | select S.materiel_code,R.seq as step_seq,S.step_code,S.unprice,R.first_choke as isbott,R.last_choke as isend from TPrteStep_Price S |
| | | inner join TFlw_Rtdt R on S.route_code=R.rout_code and S.step_code=R.step_code |
| | | where S.materiel_code=@partcode and S.route_code=@route_code |
| | | union all |
| | | select @partcode as materiel_code,B.seq as step_seq,B.step_code,'0' as unprice,B.first_choke as isbott,B.last_choke as isend from TFlw_Rout A |
| | | inner join TFlw_Rtdt B on A.code=B.rout_code |
| | | where A.code=@route_code and @partcode+A.code+B.step_code |
| | | not in(select materiel_code+rout_code+step_code from TPrteEqp_Stad |
| | | not in(select materiel_code+rout_code+step_code from TPrteStep_Price |
| | | where materiel_code=@partcode and route_code=@route_code) |
| | | ) as A |
| | | left join TStep S on A.step_code=S.stepcode"; |
| | | left join TStep S on A.step_code=S.stepcode |
| | | order by A.step_seq"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@route_code", routecode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | var parents = DapperHelper.select<SubData>(sql, dynamicParams); |
| | | for (int i = 0; i < parents.Count; i++) |
| | | { |
| | | if (parents[i].flwtype == "Z") |
| | | { |
| | | //通过产品编码+工艺路线+工序编码查找对应设备信息 |
| | | sql = @"select A.eqp_code,E.name as eqp_name,A.enable,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice |
| | | from ( |
| | | select S.eqp_code,S.eqp_value,S.enable,S.stand_value,S.cavity_qty,S.unprice from TPrteEqp_Stad S |
| | | where S.materiel_code=@partcode and S.route_code=@routecode and S.step_code=@stepcode |
| | | union all |
| | | select R.eqp_code,'0' as eqp_value,'N' as enable,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Route S |
| | | inner join TFlw_Rtdt T on S.route_code=T.rout_code |
| | | inner join TFlw_Rteqp R on T.step_code=R.step_code |
| | | where S.materiel_code=@partcode and S.route_code=@routecode and T.step_code=@stepcode and S.materiel_code+S.route_code+T.step_code+R.eqp_code |
| | | not in(select materiel_code+route_code+step_code+eqp_code from TPrteEqp_Stad |
| | | where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode) |
| | | ) as A |
| | | left join TEqpInfo E on A.eqp_code=E.code"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@routecode", routecode); |
| | | dynamicParams.Add("@stepcode", parents[i].code); |
| | | var children = DapperHelper.select<EqpSubData>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | else |
| | | { |
| | | //通过产品编码+工艺路线+工序编码查找对应外协供应商信息 |
| | | sql = @"select A.eqp_code,C.name as eqp_name,A.enable,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice |
| | | from ( |
| | | select S.eqp_code,S.eqp_value,S.enable,S.stand_value,S.cavity_qty,S.unprice from TPrteEqp_Stad S |
| | | where S.materiel_code=@partcode and S.route_code=@routecode and S.step_code=@stepcode |
| | | union all |
| | | select R.eqp_code,'0' as eqp_value,'N' as enable,'0' as stand_value,'0' as cavity_qty,'0' as unprice from TMateriel_Route S |
| | | inner join TFlw_Rtdt T on S.route_code=T.rout_code |
| | | inner join TFlw_Rteqp R on T.step_code=R.step_code |
| | | where S.materiel_code=@partcode and S.route_code=@routecode and T.step_code=@stepcode and S.materiel_code+S.route_code+T.step_code+R.eqp_code |
| | | not in(select materiel_code+route_code+step_code+eqp_code from TPrteEqp_Stad |
| | | where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode) |
| | | ) as A |
| | | left join TCustomer C on A.eqp_code=C.code"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@routecode", routecode); |
| | | dynamicParams.Add("@stepcode", parents[i].code); |
| | | var children = DapperHelper.select<EqpSubData>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | } |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |
| | | mes.data = data; |
| | | mes.data = parents; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | total = 0; //总条数 |
| | | sql = @"select * from ( |
| | | select A.id,A.materiel_code as partcode,B.partname,B.partspec,A.route_code,C.name as route_name, |
| | | D.stepcode,D.stepname,A.unprice,U.username as lm_user,A.lm_date |
| | | from TPrteEqp_Stad A |
| | | D.stepcode,D.stepname,D.flwtype,A.unprice,U.username as lm_user,A.lm_date |
| | | from TPrteStep_Price A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TFlw_Rout C on A.route_code=C.code |
| | | left join TStep D on A.step_code=D.stepcode |
| | |
| | | search = search.Substring(3);//截取索引2后面的字符 |
| | | total = 0; //总条数 |
| | | sql = @"select * from ( |
| | | select A.id,A.materiel_code as partcode,B.partname,B.partspec,D.stepcode,D.stepname,A.unprice,U.username as lm_user,A.lm_date |
| | | from TPrteEqp_Stad A |
| | | select A.id,A.materiel_code as partcode,B.partname,B.partspec,D.stepcode,D.stepname,D.flwtype,A.unprice,U.username as lm_user,A.lm_date |
| | | from TPrteStep_Price A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TStep D on A.step_code=D.stepcode |
| | | left join TUser U on A.lm_user=U.usercode |
| | |
| | | bool route = dynObj.route; |
| | | if (route) //工艺路线版 |
| | | { |
| | | //工序信息 |
| | | for (int i = 0; i < json[0].children.Count; i++) |
| | | { |
| | | //当前产品工艺路线对应工序是否已设置节拍工价 |
| | | sql = @"select * from TPrteEqp_Stad |
| | | where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode"; |
| | | //当前产品工艺路线对应工序是否已设置工价 |
| | | sql = @"select * from TPrteStep_Price where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode"; |
| | | dynamicParams.Add("@partcode", json[0].partcode); |
| | | dynamicParams.Add("@routecode", json[0].defaultroute_code); |
| | | dynamicParams.Add("@stepcode", json[0].children[i].code); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | sql = @"update TPrteEqp_Stad set unprice=@unprice,lm_user=@username,lm_date=@userdate |
| | | sql = @"update TPrteStep_Price set unprice=@unprice,lm_user=@username,lm_date=@userdate |
| | | where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode"; |
| | | list.Add(new |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | sql = @"insert into TPrteEqp_Stad(materiel_code,route_code,step_code,unprice,lm_user,lm_date) |
| | | sql = @"insert into TPrteStep_Price(materiel_code,route_code,step_code,unprice,lm_user,lm_date) |
| | | values(@partcode,@routecode,@stepcode,@unprice,@username,@userdate)"; |
| | | list.Add(new |
| | | { |
| | |
| | | } |
| | | }); |
| | | } |
| | | //设备信息 |
| | | for (int j = 0; j < json[0].children[i].children.Count; j++) |
| | | { |
| | | //当前产品工艺路线对应工序设备是否已设置节拍工价 |
| | | sql = @"select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode"; |
| | | dynamicParams.Add("@partcode", json[0].partcode); |
| | | dynamicParams.Add("@routecode", json[0].defaultroute_code); |
| | | dynamicParams.Add("@stepcode", json[0].children[i].code); |
| | | dynamicParams.Add("@eqpcode", json[0].children[i].children[j].eqp_code); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | sql = @"update TPrteEqp_Stad set enable=@enable, eqp_value=@eqp_value,stand_value=@stand_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate |
| | | where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | partcode = json[0].partcode, |
| | | routecode = json[0].defaultroute_code, |
| | | stepcode = json[0].children[i].code, |
| | | eqpcode = json[0].children[i].children[j].eqp_code, |
| | | enable= json[0].children[i].children[j].enable, |
| | | eqp_value = json[0].children[i].children[j].eqp_value, |
| | | stand_value = json[0].children[i].children[j].stand_value, |
| | | cavity_qty = json[0].children[i].children[j].cavity_qty, |
| | | unprice = json[0].children[i].children[j].unprice, |
| | | username = us.usercode, |
| | | userdate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | sql = @"insert into TPrteEqp_Stad(materiel_code,route_code,step_code,eqp_code,enable,stand_value,eqp_value,cavity_qty,unprice,lm_user,lm_date) |
| | | values(@materiel_code,@route_code,@step_code,@eqp_code,@enable,@stand_value,@eqp_value,@cavity_qty,@unprice,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = json[0].partcode, |
| | | route_code = json[0].defaultroute_code, |
| | | step_code = json[0].children[i].code, |
| | | eqp_code = json[0].children[i].children[j].eqp_code, |
| | | enable = json[0].children[i].children[j].enable, |
| | | stand_value = json[0].children[i].children[j].eqp_value, |
| | | eqp_value = json[0].children[i].children[j].stand_value, |
| | | cavity_qty = json[0].children[i].children[j].cavity_qty, |
| | | unprice = json[0].children[i].children[j].unprice, |
| | | lm_user = us.usercode, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else //工序版 |
| | |
| | | for (int i = 0; i < json[0].children.Count; i++) |
| | | { |
| | | //当前产品对应工序是否已设置节拍工价 |
| | | sql = @"select * from TPrteEqp_Stad |
| | | where materiel_code=@partcode and step_code=@stepcode"; |
| | | sql = @"select * from TPrteStep_Price where materiel_code=@partcode and step_code=@stepcode"; |
| | | dynamicParams.Add("@partcode", json[0].partcode); |
| | | dynamicParams.Add("@stepcode", json[0].children[i].code); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | sql = @"update TPrteEqp_Stad set unprice=@unprice,lm_user=@username,lm_date=@userdate |
| | | sql = @"update TPrteStep_Price set unprice=@unprice,lm_user=@username,lm_date=@userdate |
| | | where materiel_code=@partcode and step_code=@stepcode"; |
| | | list.Add(new |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | sql = @"insert into TPrteEqp_Stad(materiel_code,step_code,unprice,lm_user,lm_date) |
| | | sql = @"insert into TPrteStep_Price(materiel_code,step_code,unprice,lm_user,lm_date) |
| | | values(@partcode,@stepcode,@unprice,@username,@userdate)"; |
| | | list.Add(new |
| | | { |
| | |
| | | } |
| | | }); |
| | | } |
| | | //设备信息 |
| | | for (int j = 0; j < json[0].children[i].children.Count; j++) |
| | | { |
| | | //当前产品工艺路线对应工序设备是否已设置节拍工价 |
| | | sql = @"select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode"; |
| | | dynamicParams.Add("@partcode", json[0].partcode); |
| | | dynamicParams.Add("@routecode", json[0].defaultroute_code); |
| | | dynamicParams.Add("@stepcode", json[0].children[i].code); |
| | | dynamicParams.Add("@eqpcode", json[0].children[i].children[j].eqp_code); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | sql = @"update TPrteEqp_Stad set enable=@enable,eqp_value=@eqp_value,stand_value=@stand_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate |
| | | where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | partcode = json[0].partcode, |
| | | routecode = json[0].defaultroute_code, |
| | | stepcode = json[0].children[i].code, |
| | | eqpcode = json[0].children[i].children[j].eqp_code, |
| | | enable= json[0].children[i].children[j].enable, |
| | | eqp_value = json[0].children[i].children[j].eqp_value, |
| | | stand_value = json[0].children[i].children[j].stand_value, |
| | | cavity_qty = json[0].children[i].children[j].cavity_qty, |
| | | unprice = json[0].children[i].children[j].unprice, |
| | | username = us.usercode, |
| | | userdate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | sql = @"insert into TPrteEqp_Stad(materiel_code,route_code,step_code,eqp_code,enable,stand_value,eqp_value,cavity_qty,unprice,lm_user,lm_date) |
| | | values(@materiel_code,@route_code,@step_code,@eqp_code,@enable,@stand_value,@eqp_value,@cavity_qty,@unprice,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = json[0].partcode, |
| | | route_code = json[0].defaultroute_code, |
| | | step_code = json[0].children[i].code, |
| | | eqp_code = json[0].children[i].children[j].eqp_code, |
| | | enable= json[0].children[i].children[j].enable, |
| | | stand_value = json[0].children[i].children[j].eqp_value, |
| | | eqp_value = json[0].children[i].children[j].stand_value, |
| | | cavity_qty = json[0].children[i].children[j].cavity_qty, |
| | | unprice = json[0].children[i].children[j].unprice, |
| | | lm_user = us.usercode, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //删除节拍工价表 |
| | | sql = @"delete TPrteEqp_Stad where id=@id"; |
| | | //查找工序工价表 |
| | | sql = @"select * from TPrteStep_Price where id=@id"; |
| | | dynamicParams.Add("@id", id); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | //删除节拍工价表 |
| | | sql = @"delete TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@route_code and step_code=@step_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = data.Rows[0]["materiel_code"].ToString(), |
| | | route_code = data.Rows[0]["route_code"].ToString(), |
| | | step_code = data.Rows[0]["step_code"].ToString() |
| | | } |
| | | }); |
| | | } |
| | | //删除工序工价表 |
| | | sql = @"delete TPrteStep_Price where id=@id"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |