public JobQueue toEntity(jobQueueDTO jobqueueDto, JobQueue jobQueue) { jobQueue.jobQueueCode = jobqueueDto.jobQueueCode; jobQueue.businessType = jobqueueDto.businessType; jobQueue.laneCode = jobqueueDto.laneCode; jobQueue.laneName = jobqueueDto.laneName; jobQueue.laneType = jobqueueDto.laneType; jobQueue.direction = jobqueueDto.direction; jobQueue.startTime = jobqueueDto.startTime; jobQueue.endTime = jobqueueDto.endTime; jobQueue.licensePlateNumber = jobqueueDto.licensePlateNumber; jobQueue.ocrLicensePlateNumber = jobqueueDto.ocrLicensePlateNumber; jobQueue.rfidCardNumber = jobqueueDto.rfidCardNumber; jobQueue.isOcrLicensePlateNumberSucceeded = jobqueueDto.isOcrLicensePlateNumberSucceeded; jobQueue.rfidLicensePlateNumber = jobqueueDto.rfidLicensePlateNumber; jobQueue.icCardNumber = jobqueueDto.icCardNumber; jobQueue.customsLockNumber = jobqueueDto.customsLockNumber; jobQueue.totalWeight = jobqueueDto.totalWeight; jobQueue.containerQuantity = jobqueueDto.containerQuantity; jobQueue.isEditable = true; //jobQueue.isLocked = false; //jobQueue.lockedBy = jobqueueDto.createdBy; jobQueue.releasedBy = jobqueueDto.releasedBy; jobQueue.releasedTime = jobqueueDto.releasedTime; jobQueue.releasedType = jobqueueDto.releasedType; jobQueue.releaseResult = jobqueueDto.releaseResult; jobQueue.releaseRuleResults = jobqueueDto.releaseRuleResults; List <Container> containers = new List <Container>(); foreach (var item in jobqueueDto.containers) { Container container = new Container(); List <Damage> damages = JsonConvert.DeserializeObject <List <Damage> >(item.damages.ToString()); container.containerNumber = item.containerNumber; container.damages = damages; container.isoCode = item.ocrIsoCode; container.ocrContainerNumber = item.ocrContainerNumber; containers.Add(container); } jobQueue.containers = containers; jobQueue.pictures = JsonConvert.DeserializeObject <Picture>(jobqueueDto.pictures); jobQueue.processes = JsonConvert.DeserializeObject <List <Process> >(jobqueueDto.processes); jobQueue.extras = JsonConvert.DeserializeObject <object>(jobqueueDto.extras); return(jobQueue); }
/// <summary> /// 指令解析 /// </summary> /// <param name="command"></param> /// <param name="workingQueue"></param> /// <param name="lane"></param> public void resolveCommand(Model.Domain.Command command, JobQueue workingQueue, Lane lane) { switch (command.commandName) { case "liftBarrier": //抬杆 commandExecutorResult?.Invoke(command); break; case "dropBarrier": //落杆 commandExecutorResult?.Invoke(command); break; case "printReceipt": //打印小票 commandExecutorResult?.Invoke(command); break; case "enableLane": //开启车道 lane.laneStatus = true; commandExecutorResult?.Invoke(lane); break; case "disableLane": //禁用车道 lane.laneStatus = false; commandExecutorResult?.Invoke(lane); break; case "testPrinter": //测试打印 commandExecutorResult?.Invoke(command); break; case "setKioskLedDisplay": //设置机箱LED显示屏内容 commandExecutorResult?.Invoke(command); break; case "setTopLedDisplay": //设置顶部LED显示屏内容 commandExecutorResult?.Invoke(command); break; case "requestReleaseRuleExecutor": command.commandName = "收到请求放行规则指令"; commandExecutorResult?.Invoke(command); // 回调给主窗体打印日志 jobQueueDTO jobqueueDto = jobqueueMapper.toDto(workingQueue); command.commandName = "解析jobQueudto完成,准备调用API"; commandExecutorResult?.Invoke(command); //回调给主窗体打印日志 string result = WebApi.Post(RESULT_API_URL + "/api/release-rule-executor", JsonConvert.SerializeObject(jobqueueDto)); //请求规则执行器API jobQueueDTO apiResultDto = JsonConvert.DeserializeObject <jobQueueDTO>(result); //获取返回jobQueueDTO结果 workingQueue = jobqueueMapper.toEntity(apiResultDto, workingQueue); command.commandName = "接收结果并赋值完成"; commandExecutorResult?.Invoke(command); //回调给主窗体打印日志 commandExecutorResult?.Invoke(workingQueue); //回调给主窗体更新workingQueue推送 break; case "manualRelease": dynamic commandParam = JsonConvert.DeserializeObject <Dictionary <string, string> >(command.parameter.ToString()); workingQueue.releaseResult = commandParam["releaseResult"]; workingQueue.releasedType = commandParam["releasedType"]; workingQueue.releasedBy = commandParam["releasedBy"]; workingQueue.releasedTime = commandParam["releasedTime"]; jobQueueDTO saveDbJobQueueDto = jobqueueMapper.toDto(workingQueue); //将jobQueueDTO进行持久化 WebApi.Post(RESULT_API_URL + "/api/job-queues", JsonConvert.SerializeObject(saveDbJobQueueDto), "PUT"); //入库 command.commandName = "持久化数据完成"; commandExecutorResult?.Invoke(command); //回调给主窗体打印日志 commandExecutorResult?.Invoke(workingQueue); //回调给主窗体更新workingQueue推送 break; default: commandExecutorResult?.Invoke(command); break; } }
public jobQueueDTO toDto(JobQueue jobQueue) { jobQueueDTO jobQueueDto = new jobQueueDTO(); jobQueueDto.jobQueueCode = jobQueue.jobQueueCode; jobQueueDto.businessType = jobQueue.businessType; jobQueueDto.laneCode = jobQueue.laneCode; jobQueueDto.laneName = jobQueue.laneName; jobQueueDto.laneType = jobQueue.laneType; jobQueueDto.direction = jobQueue.direction; jobQueueDto.startTime = Convert.ToDateTime(jobQueue.startTime).ToString("s") + "Z"; jobQueueDto.endTime = Convert.ToDateTime(jobQueue.endTime).ToString("s") + "Z"; jobQueueDto.licensePlateNumber = jobQueue.licensePlateNumber; jobQueueDto.ocrLicensePlateNumber = jobQueue.ocrLicensePlateNumber; jobQueueDto.isOcrLicensePlateNumberSucceeded = jobQueue.isOcrLicensePlateNumberSucceeded; jobQueueDto.rfidLicensePlateNumber = jobQueue.rfidLicensePlateNumber; jobQueueDto.rfidCardNumber = jobQueue.rfidCardNumber; jobQueueDto.icCardNumber = jobQueue.icCardNumber; jobQueueDto.customsLockNumber = jobQueue.customsLockNumber; jobQueueDto.totalWeight = jobQueue.totalWeight; jobQueueDto.containerQuantity = jobQueue.containerQuantity; jobQueueDto.releaseResult = jobQueue.releaseResult; jobQueueDto.releaseRuleResults = jobQueue.releaseRuleResults; foreach (var item in jobQueueDto.releaseRuleResults) { if (item.updateTime.EndsWith("Z") != true) { item.updateTime = DateTime.Now.ToString("s") + "Z"; } } jobQueueDto.releasedType = jobQueue.releasedType; jobQueueDto.releasedBy = jobQueue.releasedBy; jobQueueDto.releasedTime = Convert.ToDateTime(jobQueue.releasedTime).ToString("s") + "Z"; jobQueueDto.pictures = JsonConvert.SerializeObject(jobQueue.pictures); jobQueueDto.processes = JsonConvert.SerializeObject(jobQueue.processes); jobQueueDto.extras = JsonConvert.SerializeObject(jobQueue.extras); jobQueueDto.createdBy = jobQueue.laneCode; jobQueueDto.createdTime = Convert.ToDateTime(jobQueue.startTime).ToString("s") + "Z"; jobQueueDto.lastModifiedBy = jobQueue.laneCode; jobQueueDto.lastModifiedTime = Convert.ToDateTime(jobQueue.endTime).ToString("s") + "Z"; List <ContainerDTO> list = new List <ContainerDTO>(); foreach (var item in jobQueue.containers) { ContainerDTO cdto = new ContainerDTO(); cdto.containerNumber = item.containerNumber; cdto.createdBy = jobQueue.laneCode; cdto.createdTime = DateTime.UtcNow.ToString("s") + "Z"; cdto.isOcrContainerNumberSucceeded = true; cdto.jobQueueCode = jobQueue.jobQueueCode; cdto.ocrContainerNumber = item.ocrContainerNumber; cdto.lastModifiedBy = jobQueue.laneCode; cdto.lastModifiedTime = DateTime.UtcNow.ToString("s") + "Z"; cdto.ocrIsoCode = item.isoCode; cdto.damages = JsonConvert.SerializeObject(item.damages); list.Add(cdto); } jobQueueDto.containers = list; return(jobQueueDto); }