public DTOResponse Save(PlanDetailRequest request) { DTOResponse dtoResponse = new DTOResponse(); try { if (string.IsNullOrEmpty(request.PostData)) { throw new Exception("传入的参数为空!"); } long count = 0; using (IDbConnection dbConn = HelperConnection.GetConnectionFactory().OpenDbConnection()) { //获取对象值 request.Entity = HelperSerializer.GetObjectFromJsonString <PlanDetailEntity>(request.PostData); if (request.ACTION == OPAction.CREATE) { ProductEntity productEntity = dbConn.Single <ProductEntity>(x => x.PRODUCTNO == request.Entity.PRODUCTNO); if (productEntity == null) { throw new Exception("物料" + request.Entity.PRODUCTNO + "不存在!"); } //获取计划序号 SysSequenceResult sequenceResult = SysSequenceInstance.Instance().GetSysSequence("PLANID"); PlanDetailEntity entity = new PlanDetailEntity(); entity.PLANID = long.Parse(sequenceResult.SEQVALUE); entity.PLANNO = sequenceResult.SEQVALUE + "#" + request.Entity.PLANNO; entity.PLANTYPE = request.Entity.PLANTYPE; entity.LINENUM = 1; entity.LINESTATE = 0; entity.BPNO = request.Entity.BPNO; entity.BPNAME = request.Entity.BPNAME; entity.STATIONNO = request.Entity.STATIONNO; entity.MODIFYBY = SysInfo.GetCurrentUserInfo(); entity.MODIFYDATE = Utils.GetTodayDateTimeNow(); /*entity.BOMID = ""; * entity.BOMNO = ""; * entity.BOMNAME = ""; * entity.BOMBATCHNO = "";*/ entity.PRODUCTID = productEntity.ID; entity.PRODUCTNO = productEntity.PRODUCTNO; entity.PRODUCTNAME = productEntity.PRODUCTNAME; entity.PRODUCTSPEC = productEntity.PRODUCTSPEC; entity.PRODUCTCLASS = productEntity.PRODUCTCLASS; entity.PRODUCTTYPE = productEntity.PRODUCTTYPE; entity.BATCHNO = request.Entity.BATCHNO; entity.Q01 = request.Entity.Q01; entity.Q02 = 0; entity.Q03 = 0; entity.Q04 = 0; entity.Q05 = request.Entity.Q05; entity.Q06 = request.Entity.Q06; entity.MAINUNIT = productEntity.MAINUNIT; entity.BASICUNIT = productEntity.MAINUNIT; entity.REMARK1 = request.Entity.REMARK1; entity.P01 = request.Entity.P01; entity.P02 = request.Entity.P02; /*entity.REMARK2 = ""; * * entity.P03 = ""; * entity.P04 = ""; * entity.P05 = ""; * entity.P06 = ""; * entity.P07 = ""; * entity.P08 = ""; * entity.P09 = ""; * entity.P10 = ""; * entity.P11 = ""; * entity.P12 = ""; * entity.P13 = ""; * entity.P14 = ""; * entity.P15 = ""; * entity.P16 = ""; * entity.P17 = ""; * entity.P18 = ""; * entity.P19 = ""; * entity.P20 = "";*/ //插入记录 count = dbConn.Insert <PlanDetailEntity>(entity); } else if (request.ACTION == OPAction.UPDATE) { //更新记录 count = dbConn.SaveAll <PlanDetailEntity>(new List <PlanDetailEntity>() { request.Entity }); } dtoResponse.IsSuccess = true; dtoResponse.MessageText = "操作成功!" + count; return(dtoResponse); } } catch (Exception ex) { dtoResponse.IsSuccess = false; dtoResponse.MessageText = ex.Message; logger.Error((object)ex); return(dtoResponse); } }
protected DTOResponse CreateTaskByMen( MoveRequest request, IDbConnection dbCon, IDbTransaction dbTrans) { DTOResponse dtoResponse = new DTOResponse(); try { if (string.IsNullOrEmpty(request.StationNo)) { throw new Exception("参数不正确!@StationNo"); } if (string.IsNullOrEmpty(request.Destination)) { throw new Exception("参数不正确!@Destination"); } LocStationInfoEntity locStation1 = dbCon.Single <LocStationInfoEntity>(x => x.CONTROLNO == request.StationNo); if (locStation1 == null) { throw new Exception(string.Format("站台:{0}不存在!", request.StationNo)); } LocStationInfoEntity locStation2 = dbCon.Single <LocStationInfoEntity>(x => x.CONTROLNO == request.Destination); if (locStation2 == null) { throw new Exception(string.Format("站台:{0}不存在!", request.Destination)); } if (string.IsNullOrEmpty(request.PalletNo)) { request.PalletNo = "0"; } if (string.IsNullOrEmpty(request.PalletType)) { request.PalletType = "1"; } if (request.Priority < 1) { request.Priority = 1; } SysSequenceResult sysSequence = SysSequenceInstance.Instance().GetSysSequence("TASKID"); TaskEntity taskEntity = new TaskEntity() { TASKNO = long.Parse(sysSequence.SEQVALUE).ToString(), TASKDATE = Utils.GetToday(), TASKTCLASS = "3", TASKTYPE = "0", PRIORITY = request.Priority, TASKGROUPNO = "", PRETASKNO = "", STRATEGYID01 = "", STRATEGYNAME01 = "", SOURCEAREA = locStation1.GROUPNO, SOURCE01 = locStation1.STATIONNO, SOURCE02 = locStation1.CONTROLNO, STRATEGYID02 = "", STRATEGYNAME02 = "", DESTINATIONAREA = locStation2.GROUPNO, DESTINATION01 = locStation2.STATIONNO, DESTINATION02 = locStation2.CONTROLNO, TASKORDERDATA = "", CREATEDATE = Utils.GetTodayNow(), CREATEBY = SysInfo.CurrentUserName, STARTDATE = "", ENDDATE = "", CANCELDATE = "", CANCELREASON = "", TASKSTATE = "0", BILLID = "0", BILLID_LINENUM = 0, PALLETNO = request.PalletNo, PALLETTYPE = request.PalletType }; taskEntity.TASKDESC = string.Format("人工任务:从{0}到{1}", taskEntity.SOURCE02, taskEntity.DESTINATION02); long num = dbCon.Insert <TaskEntity>(taskEntity, false); dtoResponse.MessageText = "任务号:" + taskEntity.TASKNO + "容器编号:" + request.PalletNo + "从" + locStation1.CONTROLNO + "到" + locStation2.CONTROLNO; dtoResponse.IsSuccess = num == 1 ? true : false; LogService.logger.Info((object)dtoResponse.ToString()); return(dtoResponse); } catch (Exception ex) { dtoResponse.IsSuccess = false; dtoResponse.MessageText = ex.Message; LogService.logger.Error((object)ex); return(dtoResponse); } }
public DTOResponse TaskOprationByMen(TaskRequest request) { DTOResponse dtoResponse = new DTOResponse(); try { if (request.TASKOPACTION == "Cancel") { using (IDbConnection dbConnection = HelperConnection.GetConnectionFactory().OpenDbConnection()) { using (IDbTransaction dbTrans = dbConnection.OpenTransaction()) { TaskEntity taskEntity = OrmLiteReadExpressionsApi.Single <TaskEntity>(dbConnection, (Expression <Func <TaskEntity, bool> >)(x => x.TASKNO == request.TASKNO)); if (taskEntity == null) { throw new Exception("未查询到任务:" + request.TASKNO); } //dtoResponse = BPCommon.TaskCancel(dbConnection, dbTrans, taskEntity); //if (!dtoResponse.IsSuccess) //{ // dtoResponse.MessageText = "取消任务操作1失败:" + dtoResponse.MessageText; // dbTrans.Rollback(); // return dtoResponse; //} //int jobType = 2; //dtoResponse = BPCommon.OrderTask(dbConnection, dbTrans, taskEntity, jobType); //if (dtoResponse.IsSuccess) //{ // dtoResponse.MessageText = "取消任务操作2成功!" + dtoResponse.MessageText; // dbTrans.Commit(); // return dtoResponse; //} dtoResponse.MessageText = "取消任务操作2失败:" + dtoResponse.MessageText; dbTrans.Rollback(); return(dtoResponse); } } } if (request.TASKOPACTION == "OrderDCS") { using (IDbConnection dbConnection = HelperConnection.GetConnectionFactory().OpenDbConnection()) { using (IDbTransaction dbTrans = dbConnection.OpenTransaction()) { TaskEntity taskEntity = OrmLiteReadExpressionsApi.Single <TaskEntity>(dbConnection, (Expression <Func <TaskEntity, bool> >)(x => x.TASKNO == request.TASKNO)); if (taskEntity == null) { throw new Exception("未查询到任务:" + request.TASKNO); } SysSequenceResult sequenceResult = SysSequenceInstance.Instance().GetSysSequence("TASKID"); taskEntity.TASKNO = int.Parse(sequenceResult.SEQVALUE).ToString(); SqlExpression <TaskEntity> sqlExpression = dbConnection.From <TaskEntity>(); sqlExpression.Where(x => x.ID == taskEntity.ID); sqlExpression.UpdateFields.Add("TASKNO"); int count = dbConnection.UpdateOnly <TaskEntity>(taskEntity, sqlExpression); int jobType = BPCommonBase.ConvertJobtype(taskEntity.TASKTCLASS); dtoResponse = BPCommonBase.OrderTask(dbConnection, dbTrans, taskEntity, jobType); if (dtoResponse.IsSuccess) { dtoResponse.MessageText = "重新下达任务操作成功!" + dtoResponse.MessageText; dbTrans.Commit(); return(dtoResponse); } else { dtoResponse.MessageText = "重新下达任务操作失败:" + dtoResponse.MessageText; dbTrans.Rollback(); return(dtoResponse); } } } } if (request.TASKOPACTION == "Over") { List <INF_JOBFEEDBACKEntity> jobfeedbackEntityList = new List <INF_JOBFEEDBACKEntity>(); INF_JOBFEEDBACKEntity jobfeedbackEntity1 = new INF_JOBFEEDBACKEntity(); jobfeedbackEntity1.ID = Utils.GetDateTimeGuid(); jobfeedbackEntity1.JOBID = request.TASKNO; jobfeedbackEntity1.WAREHOUSEID = "none"; jobfeedbackEntity1.FEEDBACKSTATUS = "1"; jobfeedbackEntity1.ERRORCODE = "0"; jobfeedbackEntity1.ENTERDATE = Utils.GetTodayNow(); jobfeedbackEntity1.CREATEDATE = Utils.GetTodayNow(); jobfeedbackEntity1.RESPONDCOUNT = 0; jobfeedbackEntity1.STATUS = 0; jobfeedbackEntity1.FULLCOUNT = 0; jobfeedbackEntity1.ROWVERSION = 0; jobfeedbackEntityList.Add(jobfeedbackEntity1); INF_JOBFEEDBACKEntity jobfeedbackEntity2 = new INF_JOBFEEDBACKEntity(); jobfeedbackEntity2.ID = Utils.GetDateTimeGuid(); jobfeedbackEntity2.JOBID = request.TASKNO; jobfeedbackEntity2.WAREHOUSEID = "none"; jobfeedbackEntity2.FEEDBACKSTATUS = "99"; jobfeedbackEntity2.ERRORCODE = "0"; jobfeedbackEntity2.ENTERDATE = Utils.GetTodayNow(); jobfeedbackEntity2.CREATEDATE = Utils.GetTodayNow(); jobfeedbackEntity2.RESPONDCOUNT = 0; jobfeedbackEntity2.STATUS = 0; jobfeedbackEntity2.FULLCOUNT = 0; jobfeedbackEntity2.ROWVERSION = 0; jobfeedbackEntityList.Add(jobfeedbackEntity2); long num1 = 0; using (IDbConnection dbConn = HelperConnection.GetConnectionFactory().OpenDbConnection()) { foreach (INF_JOBFEEDBACKEntity jobfeedbackEntity in jobfeedbackEntityList) { long num2 = dbConn.Insert <INF_JOBFEEDBACKEntity>(jobfeedbackEntity, false); num1 += num2; } } dtoResponse.IsSuccess = num1 > 1L; dtoResponse.MessageText = "任务操作成功"; return(dtoResponse); } else { List <INF_JOBFEEDBACKEntity> jobfeedbackEntityList = new List <INF_JOBFEEDBACKEntity>(); jobfeedbackEntityList.Add(new INF_JOBFEEDBACKEntity() { ID = Utils.GetDateTimeGuid(), JOBID = request.TASKNO, WAREHOUSEID = "none", FEEDBACKSTATUS = request.TASKOPACTION, ERRORCODE = "0", ENTERDATE = Utils.GetTodayNow(), CREATEDATE = Utils.GetTodayNow(), RESPONDCOUNT = 0, STATUS = 0, FULLCOUNT = 0, ROWVERSION = 0 }); long num1 = 0; using (IDbConnection dbConn = HelperConnection.GetConnectionFactory().OpenDbConnection()) { foreach (INF_JOBFEEDBACKEntity jobfeedbackEntity in jobfeedbackEntityList) { long num2 = dbConn.Insert <INF_JOBFEEDBACKEntity>(jobfeedbackEntity, false); num1 += num2; } } dtoResponse.IsSuccess = num1 > 1L; dtoResponse.MessageText = "任务操作成功"; return(dtoResponse); } } catch (Exception ex) { dtoResponse.IsSuccess = false; dtoResponse.MessageText = ex.Message; TaskService.logger.Error((object)ex); } return(dtoResponse); }